Skip to content

Commit 581bcb0

Browse files
sim642chertianser
authored andcommitted
Slugify tag and category links (alshedivat#947)
Fixes links to jekyll-archive pages when tag/category contains spaces.
1 parent 379663b commit 581bcb0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

_layouts/post.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ <h1 class="post-title">{{ page.title }}</h1>
2323
{%- if tags != "" %}
2424
&nbsp; &middot; &nbsp;
2525
{% for tag in page.tags -%}
26-
<a href="{{ tag | prepend: '/blog/tag/' | prepend: site.baseurl}}">
26+
<a href="{{ tag | slugify | prepend: '/blog/tag/' | prepend: site.baseurl}}">
2727
<i class="fas fa-hashtag fa-sm"></i> {{ tag }}</a> &nbsp;
2828
{% endfor -%}
2929
{% endif %}
3030

3131
{%- if categories != "" %}
3232
&nbsp; &middot; &nbsp;
3333
{% for category in page.categories -%}
34-
<a href="{{ category | prepend: '/blog/category/' | prepend: site.baseurl}}">
34+
<a href="{{ category | slugify | prepend: '/blog/category/' | prepend: site.baseurl}}">
3535
<i class="fas fa-tag fa-sm"></i> {{ category }}</a> &nbsp;
3636
{% endfor -%}
3737
{% endif %}

blog/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2>{{ site.blog_description }}</h2>
2525
<ul class="p-0 m-0">
2626
{% for tag in site.display_tags %}
2727
<li>
28-
<i class="fas fa-hashtag fa-sm"></i> <a href="{{ tag | prepend: '/blog/tag/' | relative_url }}">{{ tag }}</a>
28+
<i class="fas fa-hashtag fa-sm"></i> <a href="{{ tag | slugify | prepend: '/blog/tag/' | relative_url }}">{{ tag }}</a>
2929
</li>
3030
{% unless forloop.last %}
3131
<p>&bull;</p>
@@ -77,15 +77,15 @@ <h3>
7777
{% if tags != "" %}
7878
&nbsp; &middot; &nbsp;
7979
{% for tag in post.tags %}
80-
<a href="{{ tag | prepend: '/blog/tag/' | prepend: site.baseurl}}">
80+
<a href="{{ tag | slugify | prepend: '/blog/tag/' | prepend: site.baseurl}}">
8181
<i class="fas fa-hashtag fa-sm"></i> {{ tag }}</a> &nbsp;
8282
{% endfor %}
8383
{% endif %}
8484

8585
{% if categories != "" %}
8686
&nbsp; &middot; &nbsp;
8787
{% for category in post.categories %}
88-
<a href="{{ category | prepend: '/blog/category/' | prepend: site.baseurl}}">
88+
<a href="{{ category | slugify | prepend: '/blog/category/' | prepend: site.baseurl}}">
8989
<i class="fas fa-tag fa-sm"></i> {{ category }}</a> &nbsp;
9090
{% endfor %}
9191
{% endif %}

0 commit comments

Comments
 (0)