在Jekyll-Bootstrap中使用分类过滤文章

9

我是Jekyll和Jekyll-Bootstrap的新手。

我发现可以通过以下方式按类别进行过滤:

<ul class="posts">
{% for post in site.posts %}
    {% if post.categories contains 'demography' %}
        <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
    {% endif %}
{% endfor %}
</ul>

当我尝试将标签和分类组合时,它不起作用。
<ul class="posts">
{% for post in site.posts %}
    {% if post.categories contains 'demography' and post.tags contains 'R' %} %}
        <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
    {% endif %}
{% endfor %}
</ul>

有什么想法吗?

提前感谢!


简单来说,你可以只使用两个嵌套的if语句。 - huon
1个回答

4

第三行有一个%}多余的符号。

除此之外,它应该可以正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接