【发布时间】:2021-06-25 06:13:12
【问题描述】:
我想在 Jekyll 博客中显示当前类别的帖子。所以,我写了如下代码。
<div class="side-left col-sm-4 col-md-4">
{% for category in site.categories %}
{% if page.categories == category.first %}
<h3 class="lead"> {{ category | first }} </h3><hr>
<ul>
{% for post in category[1] limits:5 %}
<li><a href="{{ post.url }}" style="color:whitesmoke;"> {{ post.title | truncate:40 }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</div>
但是当我更新博客时,侧边栏没有任何反应。为了考试,我在第 2 行和第 3 行之间写了 {{ page.categories }} {{ category.first }}。侧边栏显示了我
A A A B A C A D
什么是问题以及如何解决?
【问题讨论】: