我在Jekyll的index.html中有以下代码。 我试图找到一种将与每篇文章相关联的类别链接到实际帖子本身的方法。 所以,如果一篇文章包含"travel"类别,我想单击一个名为"travel"的链接,它会将我带到所有分类为这样的帖子。
<ul class="post-list" style="list-style-type: none;">
{% for post in paginator.posts %}
{% unless post.categories contains 'portfolio' %}
<li>
<h3><a href="{{ post.url }}">{{ post.title }}</a></h3>
<span class="post-meta">{{ post.date | date: "%c" }}</span>
Filed In:
{% unless p.categories == empty %}
{% for categories in post.categories %}
<a href="/{{ categories | first }}">{{ categories }}</a> //problem area
{% endfor %}
{% endunless %}
{{ post.excerpt }} <a href="{{ post.url }}">Find out more...</a><br><br>
</li>
{% endunless %}
{% endfor %}
</ul>
slugify
来创建锚点,将A multi word category
转换为a-multi-word-category
。 - pgr