hugo/docs/content/en/variables/menus.md
2023-07-29 11:17:28 +02:00

3 KiB

title description categories keywords menu weight aliases
Menu variables Use these variables and methods in your menu templates.
variables and parameters
menus
docs
parent weight
variables 50
50
/variables/menu/

Variables

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.
.Menu
(string) The identifier of the menu that contains the menu entry.
.Name
(string) The name property of the menu entry.
.Page
(page) A reference to the page associated with the menu entry.
.Params
(map) The params property of the menu entry.
.Parent
(string) The parent property of the menu entry.
.Post
(template.HTML) The post property of the menu entry.
.Pre
(template.HTML) The pre property of the menu entry.
.Title
(string) The title property of the menu entry.
.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.
.Weight
(int) The weight property of the menu entry.

Methods

.HasChildren
(bool) Returns true if .Children is non-nil.
.IsEqual
(bool) Returns true if the compared menu entries represent the same menu entry.
.IsSameResource
(bool) Returns true if the compared menu entries point to the same resource.
.Page.HasMenuCurrent
(bool) Use this method to determine ancestors of the active menu entry. See details.
.Page.IsMenuCurrent
(bool) Use this method to determine the active menu entry. See details.