在 Jekyll 中列出与 post 关联的类别

List categories associated with post in Jekyll

我正在使用 Jekyll 作为我的博客平台,它很棒。现在我有以下代码,我试图在我的 index.html 页面中进行调整,以便它只显示与每个 post 关联的类别。

例如,假设我有以下 posts:

| Post Name    | Category      | 
|--------------|---------------|
| Post1        | Travel Dining | 
| Post2        | Projects      | 

当 post 列表显示时,我想得到如下内容: Post1, 6/7/15, 分类:旅游餐饮

这是我的代码: 归档于: {% for category in site.categories %} <a href="/{{ category | first | slugize }}/">{{ category | first }}</a> {% endfor %}

你的问题不清楚,但也许这段代码可以完成这项工作。

<ul>
{% for p in site.posts %}
    <li>
        <a href="{{p.url}}">{{p.title}}</a> -
        {{ p.date | date: "%a, %b %d, %y" }}
            {% unless p.categories == empty %}
                -
                {% for cat in p.categories %}
                    <h1>{{ cat }}</h1>
                {% endfor %}
            {% endunless %}
    </li>
{% endfor %}
</ul>