在试图解决这个问题的过程中,我也发现了这个悬而未决的问题。
这是一个解决方案:
// Iterate through all categories
{% for category in contents.categories %}
// Assign the current iteration category to a variable
{% assign loopCategory = category %}
// with_scope the current iteration category
{% with_scope category: loopCategory %}
// Check if this category has been assigned to any content entries (posts, or
whatever else you might be classifying)
{% if contents.posts != empty %}
{% for post in contents.posts %}
// display your post / content entry info
{% endfor %}
{% else %}
{% endif %}
{% endwith_scope %}
{% endfor %}
这将适用于标准页面。我预计模板化页面可能会出现更多问题,但我也需要实现这一点,因此当/如果我找到解决方案时会更新我的答案。