picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 615 forks source link

Hiding items in menu #512

Closed Zarxrax closed 4 years ago

Zarxrax commented 4 years ago

I am trying to keep a page from being listed on my main menu. I see that in Pico version 2.0.1 that there is a "Hidden" meta header to manually hide a page in the pages list. I tried adding "Hidden: true" to my YAML for the page I want to hide, but this did not hide the page from the menu. Does additional code need to be added to my theme to support this? Or am I simply misunderstanding what this feature does?

PhrozenByte commented 4 years ago

Your theme is likely not evaluating the page.hidden variable. Make sure that there's a not page.hidden condition in the {% for %} loop of your index.twig, like in the following example:

<ul class="nav">
    {% for page in pages if not page.hidden %}
        <li><a href="{{ page.url }}">{{ page.title }}</a></li>
    {% endfor %}
</ul>
Zarxrax commented 4 years ago

That worked great, thanks!