【问题标题】:Filtering posts using categories in Jekyll-Bootstrap在 Jekyll-Bootstrap 中使用类别过滤帖子
【发布时间】:2012-08-17 14:52:46
【问题描述】:

我是使用 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>

有什么想法吗?

提前致谢!

【问题讨论】:

  • 简单来说,你可以只使用 2 个相互嵌套的 if 语句。

标签: jekyll liquid


【解决方案1】:

您在第 3 行的 %} 太多了。

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

【讨论】:

    猜你喜欢
    • 2015-11-09
    • 2014-12-12
    • 2019-03-26
    • 1970-01-01
    • 2021-06-23
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 1970-01-01
    相关资源
    最近更新 更多