github.com/rabbouni145/gg@v0.47.1/docs/content/en/variables/menus.md (about) 1 --- 2 title: Menu Entry Properties 3 linktitle: Menu Entry Properties 4 description: A menu entry in a menu-template has specific variables and functions to make menu management easier. 5 date: 2017-03-12 6 publishdate: 2017-03-12 7 lastmod: 2017-03-12 8 categories: [variables and params] 9 keywords: [menus] 10 draft: false 11 menu: 12 docs: 13 title: "variables defined by a menu entry" 14 parent: "variables" 15 weight: 50 16 weight: 50 17 sections_weight: 50 18 aliases: [/variables/menu/] 19 toc: false 20 --- 21 22 A **menu entry** has the following properties available that can be used in a 23 [menu template][menu-template]. 24 25 ## Menu Entry Variables 26 27 .Menu 28 : _string_ <br /> 29 Name of the **menu** that contains this **menu entry**. 30 31 .URL 32 : _string_ <br /> 33 URL that the menu entry points to. The `url` key, if set for the menu entry, 34 sets this value. If that key is not set, and if the menu entry is set in a page 35 front-matter, this value defaults to the page's `.RelPermalink`. 36 37 .Page 38 : _\*Page_ <br /> 39 Reference to the [page object][page-object] associated with the menu entry. This 40 will be non-nil if the menu entry is set via a page's front-matter and not via 41 the site config. 42 43 .Name 44 : _string_ <br /> 45 Name of the menu entry. The `name` key, if set for the menu entry, sets 46 this value. If that key is not set, and if the menu entry is set in a page 47 front-matter, this value defaults to the page's `.LinkTitle`. 48 49 .Identifier 50 : _string_ <br /> 51 Value of the `identifier` key if set for the menu entry. This value must be 52 unique for each menu entry. **It is necessary to set a unique identifier 53 manually if two or more menu entries have the same `.Name`.** 54 55 .Pre 56 : _template.HTML_ <br /> 57 Value of the `pre` key if set for the menu entry. This value typically contains 58 a string representing HTML. 59 60 .Post 61 : _template.HTML_ <br /> 62 Value of the `post` key if set for the menu entry. This value typically contains 63 a string representing HTML. 64 65 .Weight 66 : _int_ <br /> 67 Value of the `weight` key if set for the menu entry. If that key is not set, 68 and if the menu entry is set in a page front-matter, this value defaults to the 69 page's `.Weight`. 70 71 .Parent 72 : _string_ <br /> 73 Name (or Identifier if present) of this menu entry's parent **menu entry**. The 74 `parent` key, if set for the menu entry, sets this value. If this key is set, 75 this menu entry nests under that parent entry, else it nests directly under the 76 `.Menu`. 77 78 .Children 79 : _Menu_ <br /> 80 This value is auto-populated by Hugo. It is a collection of children menu 81 entries, if any, under the current menu entry. 82 83 ## Menu Entry Functions 84 85 Menus also have the following functions available: 86 87 [.HasChildren](/functions/haschildren/) 88 : _boolean_ <br /> 89 Returns `true` if `.Children` is non-nil. 90 91 .KeyName 92 : _string_ <br /> 93 Returns the `.Identifier` if present, else returns the `.Name`. 94 95 .IsEqual 96 : _boolean_ <br /> 97 Returns `true` if the two compared menu entries represent the same menu entry. 98 99 .IsSameResource 100 : _boolean_ <br /> 101 Returns `true` if the two compared menu entries have the same `.URL`. 102 103 .Title 104 : _string_ <br /> 105 Link title, meant to be used in the `title` attribute of a menu entry's 106 `<a>`-tags. Returns the menu entry's `title` key if set. Else, if the menu 107 entry was created through a page's front-matter, it returns the page's 108 `.LinkTitle`. Else, it just returns an empty string. 109 110 ## Other Menu-related Functions 111 112 Additionally, here are some relevant methods available to menus on a page: 113 114 .IsMenuCurrent 115 : _(menu string, menuEntry *MenuEntry ) boolean_ <br /> 116 See [`.IsMenuCurrent` method](/functions/ismenucurrent/). 117 118 .HasMenuCurrent 119 : _(menu string, menuEntry *MenuEntry) boolean_ <br /> 120 See [`.HasMenuCurrent` method](/functions/hasmenucurrent/). 121 122 123 [menu-template]: /templates/menu-templates/ 124 [page-object]: /variables/page/