Search code examples
jekylljekyll-extensions

Jekyll filter to remove pages from site.pages based on page.url?


While generating a Google site map for my (non-github) Jekyll site, I would like to exclude certain files based on the page URL (or file name). In shell-speak, something like

site.pages | grep -v forbidden_name

In Liquid, I imagine a signature something like

site.pages | exclude 'url', forbidden_name

In a related note, is there a catalog of the standard, built-in filters, tags, and generator? Something a bit handier than grep -Rl register_filter ~/.rvm/gems?


Solution

  • You can try something like

    {% for p in site.pages %}
        {% if p.url contains 'ca' %}
            {% comment %}Do nothing{% endcomment %}
        {% else %}
            {{ p.title }}
        {% endif %}
    {% endfor %}
    

    A little hacky an case unsensitive and no wild card.

    I've made a list of tags and filters that works on Github.