DrupalX

Extension
Framework

level

You can use the level property to determine the current tree level, i.e. the depth of the currently active menu item. Put differently, this value is the length of the current menu trail. If the currently active page is not part of the corresponding menu, 0 is returened.

<nav role="navigation menu">
  {% if Menu::load("main").level>0 // Don't show menu on home page %}
  <h1>Menu</h1>
  {{ Menu::load("main") }}
  {% endif %}
</nav>