Using Grav for the First Time! Question about Grav menus

Hi! I’m using Grav as my CMS and it’s my first time using it. I’ve figured out pages…i think, but I can’t figure out how to change the items on the menu. I’ve check the various YAMl files but I haven’t found it. Am I missing something?

@paulhibbitts I’m curious about this as well and wondered if you had any thoughts. I know on our documentation site stuff seems to just show up automatically but part of me thinks some of that is theme-related? I know for that theme we’re on it was very particular about the folder structure but I’m drawing a blank as to how it works.

If it makes any difference I’m using Twenty theme

Hey there! This might be foolish to suggest, but the Grav tutorial has some info on configuring menus in the first section. This might be relevant:

If you wish to change the name that shows up in the Menu, simply add: menu: My Page between the dashes in the page content.

If you’re way beyond that step and I’m just misinterpreting what you need, my apologies! I’m also tinkering with Grav for the first time (or will be this weekend) so I’m learning right along with you. :slight_smile:

1 Like

Hi @Jessica_Reingold, awesome to hear you are checking out Grav! :slightly_smiling_face:

The relationship between a theme and site structure with Grav is much more tightly-coupled than with other CMSs like WordPress. I found this article helpful in describing this aspect of Grav: Traditional CMS Platforms and Grav | Grav CMS. I just took a look at what menu support is included in Twenty (related code contained in the Twig file /themes/twenty/templates/partial/header.html.twig) and it seems to not automatically create menu items for top-level pages as you add them. However, it does include support for adding custom buttons (like “Sign-Up”).

Are you looking to create a site with multiple pages and have each page automatically included in the menu bar? If so, another Grav theme with built-in support for multiple page sites might be more suitable, such as Antimatter, Bootstrap, Course Hub (my own theme), etc. It would be possible to do what you want with Twenty with using some custom Twig and using the theme inheritance technique so your customizations are not lost during future theme updates.

Please let me know if the above helps, and feel free to post any follow-up questions about Grav.

Cheers,
Paul
ps - if you are interested in experimenting a bit, here is a quick stab at some revised Twig code that would replace the existing code in that file ( /themes/twenty/templates/partial/header.html.twig) which would then give you an auto-generated menu of top-level pages:

<header id="header" class="{{ page.header.header_class }}">
  <h1 id="logo"><a href="{{ base_url_absolute }}">{{ site.logo.text1 }} <span>{{ site.logo.text2 }}</span></a></h1>
  <nav id="nav">
    <ul>
      {% for page in pages.children %}
      {% if page.visible %}
      {% set current_page = (page.active or page.activeChild) ? 'current' : '' %}
      <li class="{{ current_page }}">
        <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 %}
      </li>
    </ul>
  </nav>
</header>

header.html.twig (685 Bytes)

Hope you enjoy exploring Grav @Haley! Please feel free to post any questions you have here as well.

Thanks so much! I’m excited to start–certain I’ll flail around before I know what I’m doing, but that’s half the point.

1 Like

Hi ,
I am using Photographer theme, but I have a problem with submenu. In fact I have an example with submenu in this theme but I need to order it , to put the second, not only in the end of the menu item.
Thank you for your helps!