1
votes

I'm making a Jekyll site where I have different categories of posts. On the homepage, i want to display every post except those with the category advertisement. However, this code doesn't filter advertisements. Is there a way to do it in Jekyll's api?

     {% for post in site.posts %}   
     {% if post.category != advertisement %}
    <li>
        <figure>
            <img src="{{ site.url }}/img/large/{{ post.photo }}" alt="img"/>
            <figcaption><h3>{{ post.caption_header}}</h3><p>{{ post.caption }}</p></figcaption>
        </figure>
    </li>
    {% endif %}
    {% endfor %}
1
Do you just need quotes around advertisement?matt
@matt yeah that workedBrainLikeADullPencil

1 Answers

2
votes

!= is a valid Liquid operator. Please see the list here.

As what matt said, I think you need quotes around advertisement.

{% if post.category != "advertisement" %}