Skip to content

Commit ff240ed

Browse files
committed
Use absolute permalinks instead of relative paths for links
Fixes links in subfolders. See getzola/zola#128 for a detailed description of the problems with `page.path`.
1 parent 7590050 commit ff240ed

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

blog/templates/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</p>
1717
<p>Latest post:
1818
{% set latest_post = posts|last %}
19-
<strong><a href="{{ latest_post.path }}">{{ latest_post.title }}</a></strong>
19+
<strong><a href="{{ latest_post.permalink | safe }}">{{ latest_post.title }}</a></strong>
2020
</p>
2121
</div>
2222

@@ -47,10 +47,10 @@
4747
<h1>{{ extra.title }}</h1>
4848
<ul>
4949
{% for subsection in extra.subsections|reverse %}
50-
<li><a href="{{ subsection.path }}">{{ subsection.title }}</a></li>
50+
<li><a href="{{ subsection.permalink | safe }}">{{ subsection.title }}</a></li>
5151
{% endfor %}
5252
{% for page in extra.pages|reverse %}
53-
<li><a href="{{ page.path }}">{{ page.title }}</a></li>
53+
<li><a href="{{ page.permalink | safe }}">{{ page.title }}</a></li>
5454
{% endfor %}
5555
</ul>
5656

blog/templates/macros.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% macro post_link(page) %}
22
<article>
3-
<h2 class="post-title"><a href="{{ page.path }}">{{ page.title }}</a></h2>
3+
<h2 class="post-title"><a href="{{ page.permalink | safe }}">{{ page.title }}</a></h2>
44
{{ page.summary | safe }}
55
</article>
66
{% endmacro post_link %}

blog/templates/page.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ <h2>Table of Contents</h2>
2828
<hr>
2929
<div class="PageNavigation">
3030
{% if page.previous %}
31-
<a class="prev" href="{{ page.previous.path }}">&laquo; {{ page.previous.title }}</a>
31+
<a class="prev" href="{{ page.previous.permalink | safe }}">&laquo; {{ page.previous.title }}</a>
3232
{% endif %}
3333
{% if page.next %}
34-
<a class="next" href="{{ page.next.path }}">{{ page.next.title }} &raquo;</a>
34+
<a class="next" href="{{ page.next.permalink | safe }}">{{ page.next.title }} &raquo;</a>
3535
{% endif %}
3636
</div>
3737

0 commit comments

Comments
 (0)