Jekyll,显示单个帖子的类别

时间:2015-03-09 15:18:44

标签: jekyll categories liquid

使用Jekyll - 我想显示给定帖子所属的类别列表。

在我的post.html布局中,我有以下代码块来呈现所有网站的类别。

<p>Posted in: 
  {% for category in site.categories %}
    <a href="/blog/{{ category | first | slugize }}/">
      {{ category | first }}
    </a>
  {% endfor %}
</p>

我想要显示的是此单个帖子所属类别的列表。我尝试用page.categories&amp;更换site.categories。 post.categories,无济于事。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

不使用site.categories,而是使用page.categories。此外,您不需要first - 过滤器,因为您已遍历数组:

{% for category in page.categories %}
  <a href="/blog/{{ category | slugize }}/">
    {{ category }}
  </a>
{% endfor %}