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