sdaza
sdaza

Reputation: 1052

Filtering posts using categories in Jekyll-Bootstrap

I am new using Jekyll and Jekyll-Bootstrap.

I have found this for filtering by category:

<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>

When I try to combine tags and categories it doesn't work:

<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>

Any idea?

Thanks in advance!

Upvotes: 9

Views: 8830

Answers (1)

Polygnome
Polygnome

Reputation: 7795

You have a %} too much in line #3.

Other than that, it should work fine.

Upvotes: 4

Related Questions