Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering posts using categories in Jekyll-Bootstrap

Tags:

jekyll

liquid

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!

like image 483
sdaza Avatar asked Aug 17 '12 14:08

sdaza


1 Answers

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

Other than that, it should work fine.

like image 119
StandByUkraine Avatar answered Sep 18 '22 15:09

StandByUkraine