The simplify_menu module uses a TwigExtension to gain access to Drupal's main menu's (or any other menu for that matter), render array so it can be accessed from a twig template. Among the many advantages of having full control of the menu's render array in a twig template is the ability to customize the markup for your menus to ensure they are accessible and comply with standards.
How to use
{# Get menu items #}
{% set items = simplify_menu('main') %}
{# Iterate menu tree #}
<nav class="navigation__items">
{% for menu_item in items.menu_tree %}
<li class="navigation__item">
<a href="{{ menu_item.url }}">{{ menu_item.text }}</a>
</li>
{% endfor %}
</nav>
Blog post
Read a detailed blog post by Tim Dickens of Mediacurrent.
https://www.mediacurrent.com/blog/simplify-menu-and-twig-macros
Supporting organizations:
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Site structure
7,987 sites report using this module
- Created by jmolivas on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
3.3.0
released 13 December 2024
Works with Drupal: ^9 || ^10 || ^11
Drupal 11 support and automated tests
Install:
Development version: 3.x-dev updated 13 Dec 2024 at 15:50 UTC






