2019-10-21 04:22:28 -04:00
---
2023-07-29 05:15:54 -04:00
title: Menu variables
2023-05-22 10:43:12 -04:00
description: Use these variables and methods in your menu templates.
2023-07-29 05:15:54 -04:00
categories: [variables and parameters]
2019-10-21 04:22:28 -04:00
keywords: [menus]
menu:
docs:
2023-05-22 10:43:12 -04:00
parent: variables
2019-10-21 04:22:28 -04:00
weight: 50
weight: 50
aliases: [/variables/menu/]
---
2023-05-22 10:43:12 -04:00
## Variables
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
After [defining menu entries], access their properties in [menu templates] with these variables.
.Children
: (`menu`) A collection of child menu entries, if any, under the current menu entry.
.Identifier
: (`string`) The `identifier` property of the menu entry. If you define the menu entry [automatically], the page's `.Section` .
.KeyName
: (`string`) The `identifier` property of the menu entry, else the `name` property.
2019-10-21 04:22:28 -04:00
.Menu
2023-05-22 10:43:12 -04:00
: (`string`) The identifier of the menu that contains the menu entry.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
.Name
: (`string`) The `name` property of the menu entry.
- If you define the menu entry [automatically], the page's `.LinkTitle` , else the page's `.Title` .
- If you define the menu [in front matter] or [in site configuration], falls back to the page's `.LinkTitle` , then to the page's `.Title` .
2019-10-21 04:22:28 -04:00
.Page
2023-05-22 10:43:12 -04:00
: (`page`) A reference to the page associated with the menu entry.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
<!-- This provides no value when rendering menu. Omitting to avoid confusion.
2022-11-17 10:14:29 -05:00
.PageRef
2023-05-22 10:43:12 -04:00
: (`string`) The `pageRef` property of the menu entry.
-->
2021-08-03 05:51:36 -04:00
2023-05-22 10:43:12 -04:00
.Params
: (`map`) The `params` property of the menu entry.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
.Parent
: (`string`) The `parent` property of the menu entry.
.Post
: (`template.HTML`) The `post` property of the menu entry.
2019-10-21 04:22:28 -04:00
.Pre
2023-05-22 10:43:12 -04:00
: (`template.HTML`) The `pre` property of the menu entry.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
.Title
: (`string`) The `title` property of the menu entry.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
- If you define the menu entry [automatically], the page's `.LinkTitle` , else the page's `.Title` .
- If you define the menu [in front matter] or [in site configuration], falls back to the page's `.LinkTitle` , then to the page's `.Title` .
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
.URL
: (`string`) The `.RelPermalink` of the page associated with the menu entry. For menu entries pointing to external resources, the `url` property of the menu entry.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
.Weight
: (`int`) The `weight` property of the menu entry.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
- If you define the menu entry [automatically], the page's `.Weight` .
- If you define the menu [in front matter] or [in site configuration], falls back to the page's `.Weight` .
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
## Methods
2019-10-21 04:22:28 -04:00
.HasChildren
2023-05-22 10:43:12 -04:00
: (`bool`) Returns `true` if `.Children` is non-nil.
2019-10-21 04:22:28 -04:00
.IsEqual
2023-05-22 10:43:12 -04:00
: (`bool`) Returns `true` if the compared menu entries represent the same menu entry.
2019-10-21 04:22:28 -04:00
.IsSameResource
2023-05-22 10:43:12 -04:00
: (`bool`) Returns `true` if the compared menu entries point to the same resource.
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
.Page.HasMenuCurrent
: (`bool`) Use this method to determine ancestors of the active menu entry. See [details ](/functions/hasmenucurrent/ ).
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
.Page.IsMenuCurrent
: (`bool`) Use this method to determine the active menu entry. See [details ](/functions/ismenucurrent/ ).
2019-10-21 04:22:28 -04:00
2023-05-22 10:43:12 -04:00
[automatically]: /content-management/menus/#define-automatically
[defining menu entries]: /content-management/menus/#overview
[in front matter]: /content-management/menus/#define-in-front-matter
[in site configuration]: /content-management/menus/#define-in-site-configuration
[menu templates]: /templates/menu-templates/