Using Blog: Is there a way to exclude pages from a listing (but keep them published)?

Hey all,

I’m very new to grav, and I’ve discovered using the blog template that I can set published: true or false, so I can work on (and save) a page as I’m building it.

However, what I’d like is to have a page published, but hidden from the listing and the RSS feed so I can show it to people before it’s in the RSS (which triggers syndication elsewhere) and view the final version for formatting and editing.

Is this easily possible?

Hi @gushi, I’ve done something like this to hide posts in a blog listing page in my Open Course Hub Bootstrap theme using a bit of custom Twig and a page frontmatter variable called hide_from_post_list. However, this does not address your RSS feed issue.

Here is a generalized example of the Twig:

        {% for child in collection %}
          {% if child.header.hide_from_post_list != true %}
            {% include 'partials/blog_item.html.twig' with {'blog':page, 'page':child, 'truncate':true} %}
          {% endif %}
        {% endfor %}

If you download my Open Course Hub skeleton you can explore a working example https://getgrav.org/downloads/skeletons

Hope the above helps!

A custom header like Paul suggested is exactly what you need in situations like this. There’s nothing in Grav to stop you just adding your own headers for your own purposes and using those as needed (e.g. filtering a list) in Twig.

You could simply edit the RSS template to achieve the same thing.

(BTW I’d simplify Paul’s template as

{% for child in collection if child.header.hide_from_post_list != true %}
  {% include 'partials/blog_item.html.twig' with {'blog':page, 'page':child, 'truncate':true} %}
{% endfor %}

Twig for loops have some cool extras! And I might add child.header.hide_from_post_list is defined and in front of the if to allow you to be lazier.)

Also, there are probably better ways to manage this whole review/release process. Have a look for plugins that let you allow only certain logged in users to see your content. That seems more robust than hoping search engines don’t accidentally index your unreleased content. Sorry would suggest but short on time now.

Here BTW for private site areas.

And a later edit: I just found good recipes in the docs for private areas.