Skip to content

Commit

Permalink
Slugify tag and category links (alshedivat#947)
Browse files Browse the repository at this point in the history
Fixes links to jekyll-archive pages when tag/category contains spaces.
  • Loading branch information
sim642 committed Oct 16, 2022
1 parent 7d7567e commit 5f3c487
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ <h1 class="post-title">{{ page.title }}</h1>
{%- if tags != "" %}
&nbsp; &middot; &nbsp;
{% for tag in page.tags -%}
<a href="{{ tag | prepend: '/blog/tag/' | prepend: site.baseurl}}">
<a href="{{ tag | slugify | prepend: '/blog/tag/' | prepend: site.baseurl}}">
<i class="fas fa-hashtag fa-sm"></i> {{ tag }}</a> &nbsp;
{% endfor -%}
{% endif %}

{%- if categories != "" %}
&nbsp; &middot; &nbsp;
{% for category in page.categories -%}
<a href="{{ category | prepend: '/blog/category/' | prepend: site.baseurl}}">
<a href="{{ category | slugify | prepend: '/blog/category/' | prepend: site.baseurl}}">
<i class="fas fa-tag fa-sm"></i> {{ category }}</a> &nbsp;
{% endfor -%}
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>{{ site.blog_description }}</h2>
<ul class="p-0 m-0">
{% for tag in site.display_tags %}
<li>
<i class="fas fa-hashtag fa-sm"></i> <a href="{{ tag | prepend: '/blog/tag/' | relative_url }}">{{ tag }}</a>
<i class="fas fa-hashtag fa-sm"></i> <a href="{{ tag | slugify | prepend: '/blog/tag/' | relative_url }}">{{ tag }}</a>
</li>
{% unless forloop.last %}
<p>&bull;</p>
Expand Down Expand Up @@ -77,15 +77,15 @@ <h3>
{% if tags != "" %}
&nbsp; &middot; &nbsp;
{% for tag in post.tags %}
<a href="{{ tag | prepend: '/blog/tag/' | prepend: site.baseurl}}">
<a href="{{ tag | slugify | prepend: '/blog/tag/' | prepend: site.baseurl}}">
<i class="fas fa-hashtag fa-sm"></i> {{ tag }}</a> &nbsp;
{% endfor %}
{% endif %}

{% if categories != "" %}
&nbsp; &middot; &nbsp;
{% for category in post.categories %}
<a href="{{ category | prepend: '/blog/category/' | prepend: site.baseurl}}">
<a href="{{ category | slugify | prepend: '/blog/category/' | prepend: site.baseurl}}">
<i class="fas fa-tag fa-sm"></i> {{ category }}</a> &nbsp;
{% endfor %}
{% endif %}
Expand Down

0 comments on commit 5f3c487

Please sign in to comment.