Share icon

If you want to render the menu items in custom way in page or node twig template of drupal 8 then this article is for you :


At man place where you make the template in drupal theming you want to render your menu in different style, For example main menu at header shows in different style while in footer in different style, for that you need to code on twig template but you don't know much about twig the simply use this module called "simplify menu"


This module allow you to make render your menu in own style, visit the above link get you more information or just install the module and paste the below code in your template with updated menu name and that done.

{# 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>
  {% endfor %}


using above code you will able to render any content in any page template.

Add new comment

Restricted HTML