Render pages in different menus

Hello folks,
I am doing a multi-lang project.
I need to separate the menu in two sections:

  1. Main menu for the core navigation of the website
  2. Footer navigation for stuff like legal, privacy, …
    All should be handable via pages

My questions: how can I tell a macro only to take some pages (e.g. marked as “footer”) for the creation of a list of page links?

Spoiler: Cannot hardcode it: otherwise multilanguage will die.

So what I have found out so far…
I found a quite ok solution. I add every link that I want to appear in a specific menu with the following code:

{% set c_page = page.find('/blog') %}
<li class="menu-item {% if c_page.active %}active{% endif %}">
<a href="{{c_page.url}}">{{c_page.menu}}</a>
</li>

This example adds the page in the folder “blog”.

I am not a fan of it because:

  • It is not a proper function :-/
  • I have to go in code and cannot add pages in the admin
  • It has a bug with multi-language: when I switch languages, it renders the url out of the english path-name for the page. Thus I get URLs that are not the right ones for the languages as specified in the href-lang tags. Might confuse search engines.

Anyone some other solution in mind? :slight_smile:

Hello,

You could add a specific field in your pages blueprint and render them in the menu depending on the value of that field.

It could be a taxonomy field, it could be a bolean “menuFooter : true” or even a select field.

I’m not sure if it’s the best option, but it’s what I would do.

I remember someone doing it differently, he had a “page” (a page in the admin) not indexed and not rendered in the menu, with the content being a list of links. And he included this page in his footer.
This way, you don’t have to change a value in each pages, but simply modify that “page”.

yes, that could work. I was too lazy doing that and hoped I was missing a feature :smiley:
It could even be a multi-select if you have several menus.
Thanks AmauryH