首先,情景:
我在X类中有一些文档,它们有标签Y,Z,W。
我想分组然后,我可以做这样的事情到文件
任何提示?
试过这段代码
<ul>
{% for tag in site.categories.personagens.tags %}
<li/> {{ tag }}
<ul/>
{% for posts in tag %}
<li/><a href="{{ post.url }}">{{ post.title | markdownify | remove: '<p>' | remove: '</p>' }}</a>
{% comment %}
{{ post.content }}
{% endcomment %}
{% endfor %}
{% endfor %}
</ul>
但它没有奏效......
答案 0 :(得分:1)
你可以试试这个:
{% comment %}Posts will be filtered by one category{% endcomment %}
{% assign filterCategory = "works" %}
{% for tag in site.tags %}
{% comment %}creates an empty array{% endcomment %}
{% assign postsInCategory = "" | split: "/" %}
{% comment %}looping over site.tags{% endcomment %}
{% for post in tag[1] %}
{% if post.categories contains filterCategory %}
{% comment %}if a post is from our filter category we add it to postsInCategory array{% endcomment %}
{% assign postsInCategory = postsInCategory | push: post %}
{% endif %}
{% endfor %}
{% if postsInCategory.size > 0 %}
<h1>{{ tag[0] }}</h2>
{% for post in postsInCategory %}
<h2><a href="{{ site.baseurl }}{{ post.url }}"></a>{{ post.title }}</h2>
{% endfor %}
{% endif %}
{% endfor %}