在Jekyll中,我目前能够在首页上列出收藏集/帖子,但标签未显示。
对于这项工作,我尝试使用半自定义循环,但它没有像下面的示例代码那样列出标签,并且期望显示带有标签的节目集/帖子,但是没有。
{% assign ordered_works = site.works | sort:"work-order" %}
{% for work in ordered_works reversed limit: 3 %}
<div class="scene">
<div class="featured-works__item featured-works__item--blue tween-animation">
<picture class="featured-works__item-thumb">
<source
media="(min-width: 768px)"
srcset="/assets/images/works/{{ work.thumb-image }}.png 1x, /assets/images/works/{{ work.thumb-image }}@2x.png 2x"
>
<source
media="(max-width: 767px)"
srcset="/assets/images/works/{{ work.mobile-thumb-image }}.png 1x"
>
<img
src="/assets/images/works/{{ work.thumb-image }}.png"
alt="{% if work.cover-image-alt-text != "" %}{{work.cover-image-alt-text}}{% else %}{{ work.title}}{% endif %}"
/>
</picture>
<figure>
</figure>
<div class="featured-works__item-info" {% if work.bg-color %}style="background-color: {{ work.bg-color }}" {% endif %}>
<h4>{{ work.title }}</h4>
<h5>{{ work.sub-title }}</h5>
<ul>
{% for tag in page.tags %}
<li>#{{ tag }}</li>
{% endfor %}
</ul>
<p>{{ work.summary }}</p>
<a href="{{ work.url }}" class="primary-button">Click Here to Detail</a>
</div>
</div>
</div>
{% endfor %}
答案 0 :(得分:1)
您可以将{% for tag in page.tags %}
替换为{% for tag in work.tags %}
。