Split Navigation Menus for Footer

Just getting to grips with Grav, all good so far but I have an issue with navigation that I cannot find an answer to.
I would like to hide some pages from the main navigation and instead list them in the footer section of each page.
I have found if I use ‘visible: false’ that the pages don’t appear in the main navigation which is perfect.
I can then add them to the footer using this code:-

{% for page in pages.children %}
{% if page.visible (‘false’) %}
li a href="{{ page.url }}" {{ page.menu }} /a /li
{% endif %}
{% endfor %}
{% for mitem in site.menu %}
li a href="{{ mitem.link }}" {{ mitem.text }} /a /li
{% endfor %}

(not sure how to add code with the <> in place)

but this also shows the pages that are marked as visible.
How can I exclude the pages marked as visible from this list?
Or is this the wrong way of solving this issues?

Hi @fatbuddhadesigns, this is not tested but this should provide a for loop with only visible pages:

{% for page in pages.children.visible %}

I hope the above is helpful.

Hello Paul

That displays pages that are marked as visible: true , in this particular case I am trying to display pages that are marked as visible: false.
These will give a navigation menu to such pages as my cookies and privacy policy which I don’t want to display in the main navigation, but in the footer instead.



Hi @fatbuddhadesigns, sorry that I misread your question🙂

try this:

{% if not (page.visible) %}

BTW, to display code here in the forum use three backticks in a row - for example:

{% if not (page.visible) %}

Let me know if then above works for you.

Thanks Paul,
That works a treat.
Will try the code format next time I am here.
Once again, thank you.

1 Like