Jekyll 每个类别如何有不同的布局?

Jekyll 每个类别如何有不同的布局?,jekyll,Jekyll,如何为帖子类别设置不同的布局 例如,如果我将“玩具”和“剑”作为帖子的类别,我希望列出“玩具”的页面的布局与列出“剑”的页面的布局不同。如果帖子属于一个没有自己布局的类别,那么最好有一个默认的“产品”布局。关于如何使用jekyll实现这一点,有什么想法吗?因为文档的语义在不同类别之间不会改变,我认为您必须使用CSS来解决这个问题 browsh\u list.html --- category: sword layout: product_listing title: swords list --

如何为帖子类别设置不同的布局


例如,如果我将“玩具”和“剑”作为帖子的类别,我希望列出“玩具”的页面的布局与列出“剑”的页面的布局不同。如果帖子属于一个没有自己布局的类别,那么最好有一个默认的“产品”布局。关于如何使用jekyll实现这一点,有什么想法吗?

因为文档的语义在不同类别之间不会改变,我认为您必须使用CSS来解决这个问题

browsh\u list.html

---
category: sword
layout: product_listing
title: swords list
---
{% include product_listing_loop %}
<div class="{{page.category}}">
<ul>
{% for post in categories[page.category] %}
  <li>{{ post.title }}</li>
{% endfor %}
</ul>
</div>
---
category: sword
layout: product_listing
title: swords list
---
{% assign include_name = 'category_' | append: {{page.category}} %} 
{% include {{include_name}} %}
\u包括/product\u清单\u loop.html

---
category: sword
layout: product_listing
title: swords list
---
{% include product_listing_loop %}
<div class="{{page.category}}">
<ul>
{% for post in categories[page.category] %}
  <li>{{ post.title }}</li>
{% endfor %}
</ul>
</div>
---
category: sword
layout: product_listing
title: swords list
---
{% assign include_name = 'category_' | append: {{page.category}} %} 
{% include {{include_name}} %}

这将调用
\u includes/category\u sbrow.html

是否要为页面自定义布局,列出一个特定类别中的所有帖子?听起来不错,(categories[page.category]很不错!),但如果我需要为每个类别使用不同的标记,该怎么办?