Jekyll array contains check

jekyll, liquid, ruby, templates

Solution

Try :

exclude_pages: [ "index.html", "anyfolder/index.html" ]

Then loop with `entry.path` not `entry.url`:

{% for entry in site.pages %}
    {% if site.exclude_pages contains entry.path %}
        <!-- Do Nothing -->
    {% else %}
        <!-- Show Page -->
    {% endif %}
{% endfor %}

Problem

I've an array in my _config.yaml. Let's say ``` exclude_pages: [ "/404.html", "/search.html", "/atom.xml", "/rss.xml", "/index.html", "/sitemap.txt" ] ``` What I want to do is exclude these pages in the pages loop of site.pages. So following is the code that I'm trying. ``` {% for entry in site.pages %} {% if site.exclude_pages contains entry.url %} <!-- Do Nothing --> {% else %} <!-- Show Page --> {% endif %} {% endfor %} ``` But somehow it is not happening. All the pages are being ignored in this code. Any idea what I'm missing here ?

Original source