Skip to content

Commit

Permalink
Use relative_url instead of prepend baseurl filter
Browse files Browse the repository at this point in the history
Jekyll 3.3 ships with relative_url filter, Which will ensure baseurl is
prepended to anything passed to it. Result of relative_url will always
safely produce URL relative to root.

goo.gl/KZLhPr
  • Loading branch information
salmanulfarzy committed Oct 14, 2017
1 parent 1fe0692 commit 04f4f23
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if site.theme_settings.katex %}
<script src="{{ "/assets/js/katex_init.js" | prepend: site.baseurl }}"></script>
<script src="{{ "/assets/js/katex_init.js" | relative_url }}"></script>
{% endif %}

{% if site.theme_settings.footer_text %}
Expand Down
6 changes: 3 additions & 3 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- CSS -->
<link rel="stylesheet" href="{{ "/assets/css/main.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{ "/assets/css/main.css" | relative_url }}">

<!--Favicon-->
<link rel="shortcut icon" href="{{ site.baseurl }}/{{ site.theme_settings.favicon }}" type="image/x-icon">

<!-- Canonical -->
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | relative_url }}">

<!-- RSS -->
<link rel="alternate" type="application/atom+xml" title="{{ site.theme_settings.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" />
<link rel="alternate" type="application/atom+xml" title="{{ site.theme_settings.title }}" href="{{ "/feed.xml" | relative_url }}" />

<!-- Font Awesome -->
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1 class="site-title">
{% for page in site.pages %}
{% if page.title and page.hide != true %}
<li>
<a class="page-link" href="{{ page.url | prepend: site.baseurl }}">
<a class="page-link" href="{{ page.url | relative_url }}">
{{ page.title }}
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion _includes/icons.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% if site.theme_settings.rss %}
<li>
<a href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" title="{{ site.theme_settings.str_rss_follow }}">
<a href="{{ "/feed.xml" | relative_url }}" title="{{ site.theme_settings.str_rss_follow }}">
<i class="fa fa-fw fa-rss"></i>
</a>
</li>
Expand Down
8 changes: 4 additions & 4 deletions _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="post-teaser">
<header>
<h1>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">
<a class="post-link" href="{{ post.url | relative_url }}">
{{ post.title }}
</a>
</h1>
Expand All @@ -25,7 +25,7 @@ <h1>
</header>
<div class="excerpt">
{{ post.excerpt }}
<a class="button" href="{{ post.url | prepend: site.baseurl }}">
<a class="button" href="{{ post.url | relative_url }}">
{{ site.theme_settings.str_continue_reading }}
</a>
</div>
Expand All @@ -36,13 +36,13 @@ <h1>
{% if paginator.total_pages > 1 %}
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}" class="button" >
<a href="{{ paginator.previous_page_path | relative_url | replace: '//', '/' }}" class="button" >
<i class="fa fa-chevron-left"></i>
{{ site.theme_settings.str_previous_page }}
</a>
{% endif %}
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}" class="button" >
<a href="{{ paginator.next_page_path | relative_url | replace: '//', '/' }}" class="button" >
{{ site.theme_settings.str_next_page }}
<i class="fa fa-chevron-right"></i>
</a>
Expand Down
6 changes: 3 additions & 3 deletions feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ layout: null
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ site.theme_settings.title | xml_escape }}</title>
<atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
<atom:link href="{{ "/feed.xml" | relative_url }}" rel="self" type="application/rss+xml"/>
<link>{{ site.url }}{{ site.baseurl }}/</link>
<description>{{ site.theme_settings.description | xml_escape }}</description>
<pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
{% for post in site.posts limit:15 %}
<item>
<title>{{ post.title | xml_escape }}</title>
<link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
<guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
<link>{{ post.url | relative_url }}</link>
<guid isPermaLink="true">{{ post.url | relative_url }}</guid>
<description>{{ post.content | xml_escape }}</description>
<pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
</item>
Expand Down
2 changes: 1 addition & 1 deletion tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2 id="{{ this_word | cgi_escape }}" class="tag-title">
{% if post.title != null %}
<div class="tagged-post">
<h3 class="title">
<a href="{{ post.url | prepend: site.baseurl }}">
<a href="{{ post.url | relative_url }}">
{{ post.title }}
</a>
</h3>
Expand Down

0 comments on commit 04f4f23

Please sign in to comment.