Skip to content
Snippets Groups Projects
Commit 29d8644d authored by Erik Strand's avatar Erik Strand
Browse files

Use relative URLs

parent feaaeb80
Branches
No related tags found
No related merge requests found
<nav>
{% for item in site.data.navigation %}
<a href="{{ item.link }}" {% if page.url == item.link %}class="current"{% endif %}>{{ item.name }}</a>
<a href="{{ item.link | real_relative_url }}" {% if page.url == item.link %}class="current"{% endif %}>{{ item.name }}</a>
{% endfor %}
</nav>
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>{{ page.title }}</title>
<link rel="stylesheet" href="/assets/css/styles.css">
<link rel="stylesheet" href="{{ "/assets/css/styles.css" | real_relative_url }}">
{% include mathjax.html %}
</head>
<body>
......
require 'pathname'
# Jekyll's built-in "relative_url" filter does not generate relative URLs, it generates URLs that
# don't contain the domain. This plugin was posted to a GitHub issue in which @aioobe asks about
# making real relative URLs: https://github.com/jekyll/jekyll/issues/6360.
module Jekyll
module RealRelativeUrl
def real_relative_url(url)
pageUrl = @context.registers[:page]["url"]
pageDir = Pathname(pageUrl).parent
Pathname(url).relative_path_from(pageDir).to_s
end
end
end
Liquid::Template.register_filter(Jekyll::RealRelativeUrl)
.current {
color: green;
font-weight: bold;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment