Reference

Menu

A Menu object holds the custom field values saved on a navigation menu, such as mega-menu content, footer copy or other data that belongs to the menu rather than to individual nodes. In templates, this is the verbb\navigation\elements\Menu element.

Query

{% set menu = craft.navigation.menu('mainMenu').one() %}

{% if menu %}
    {{ menu.promoHeading }}
{% endif %}

Use craft.navigation.menu() to query menu elements. For batch-loading menus while looping nodes, use withMenu() on Node Queries.

Properties

Menu elements expose standard Craft element properties (id, title, siteId, etc.) plus any custom fields on the menu field layout.

Methods

getMenuHandle()

Returns the menu’s handle, such as mainMenu. It’s an empty string if the menu has no handle.

Settings vs Element

APIReturnsUse for
craft.navigation.menu('handle').one()Menu elementField values in templates
craft.navigation.getMenuByHandle('handle')Menu elementSame as menu().one(), as a shortcut when you already know the handle
Navigation::$plugin->getMenus()->getMenuByHandle('handle')MenuSettings modelMenu configuration in PHP. See Menu Settings

GraphQL

Each menu has its own GraphQL type, named after its handle, such as mainMenu_Menu. The [handle]_Menu Type lists its fields.