Jekyll - 获取多个类别中的所有帖子

emp*_*e29 5 liquid jekyll

我想循环所有分配类别“foo”和类别“bar”的帖子..

{% for post in site.categories.foo and in site.categories.bar %}
Run Code Online (Sandbox Code Playgroud)

这可能吗?

在我的例子中,“foo”作为“bar”的“父”类别....../foo/bar/_posts

谢谢

小智 3

这是完全可能的:循环所有帖子,然后选择想要的帖子:

{% for post in site.posts %}
    {% if post.categories contains "foo" or post.categories contains "bar" %}
        <li><a href="{{ post.url }}">{{ post.title }}</a></li>
    {% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)