3
我在我的index.html中为Jekyll获得了以下代码。我试图找到一种方法将与每篇文章相关的类别链接到实际文章本身。所以,如果一个帖子包含“旅行”类别,我想点击一个链接,指出“旅行”,这会将我带到所有被归类的帖子。如何链接Jekyll中的帖子类别
<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>
那是'除非p.categories == empty'正确吗?什么是'p'?它看起来不对,但我不太了解这种语言,所以我只问。 – pgr
一个可能的改进是使用过滤器'slugify'来创建锚点,将'多个单词类别'变成'多个单词类别'。 – pgr