Hello, I would like custom the default menu in Drupal 8.

menu_name: The machine name of the menu.
items: A nested list of menu items. Each menu item contains:
    attributes: HTML attributes for the menu item.
    below: The menu item child items.
    title: The menu link title.
    url: The menu link url, instance of \Drupal\Core\Url
    localized_options: Menu link localized options.
{% for item in items %}
    <li><a href="{{ path(item.url.routeName) }}" {{ item.attributes }}>{{ item.title }}</a></li>
{% endfor %}

The error : An exception has been thrown during the rendering of a template ("Some mandatory parameters are missing ("node") to generate a URL for route "/node/{node}".") in "themes/bootstrap/templates/menu--secondary-.html.twig" at line 47.

How I can pass all link parameters to the path function please ? Thanks.

Comments

penyaskito’s picture

You can use:

    {{  path('entity.node.canonical', {'node': node->id()}) }}

Christian López Espínola (@penyaskito)

penyaskito’s picture

.

Christian López Espínola (@penyaskito)