Separate sub navbar

How can I build up a list of sub links to the current page?

You can check this: https://github.com/getgrav/grav-theme-antimatter/blob/develop/templates/partials/navigation.html.twig
The macro “loop” create a submenu.

Maybe your looking for what we would term as a split-menu ? By that I mean that rather than showing the dropdown menus for all pages all the time (like a traditional dropdown menu does), it only shows the children of the current page.

This could be done by simply iterating over the current page’s children if it has any. Something like (untested) :

{% if page.children %}
<h3>SubMenu</h3>
<ul id="split-menu">
  {% for child in page.children %}
    <li>
      <a href="{{ child.url }}">{{ child.menu }}</a>
    </li>
  {% endfor %}
</ul>
{% endif %}
1 Like

thanks :smiley:

Trying to adapt this code to my own site, and your code does work well. However I would like to modify it to include some more detail for each menu item. Is there anywhere I can see what each child contains? (No formal programming quals so I don’t know the apt terminology here)

For example, child.url is the url, child.menu seems to be the title of the page, I’ve found out that child.name is the actual filename. What else is there, and how can I find it out?

What I would like is to be able to use the taxonomy of each child to build the list. However using child.taxonomy() or child.taxonomy(category) returns an array (I’m guessing) which throws up an exception when loading the page.

Just add some custom header variables in each page mycustom1: foo

and then access them in the twig with {{ child.header.mycustom1 }}