我的收藏帖子有一个子类别,但我有循环问题,我只需要一个特定的子类别。
config.yml
collections:
news:
output: true
cat1:
output: true
permalink: /news/cat1/:title/
cat2:
output: true
permalink: /news/cat2/:title/
cat3:
output: true
permalink: /news/cat3/:title/
cat4:
output: true
permalink: /news/cat4/:title/
这是html文件
---
# this is an empty front matter
title: 'Cat 1 news'
permalink: /news/cat1/
---
{% for item in site.news %}
{% for post in item.cat1 %}
{{ post.title }}<br>
{% endfor %}
{% endfor %}
这是
的目录树_news
| cat1
| cat2
| cat3
| cat4
答案 0 :(得分:0)
您可以使用:
{% for post in site.cat1 %}
或
{% assign myCategory = "cat1" %}
{% for post in site[mycategory] %}