mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
bd77f6e1c9
327003421 Update index.md cafdccc13 Hugo 0.86.1 467a89a02 Merge branch 'v0861' a22c37bc9 Merge branch 'release-0.86.1' 276da91a8 releaser: Add release notes to /docs for release of 0.86.1 198cdf8f0 tpl/lang: Add new localized versions of lang.FormatNumber etc. 93f986ecc Add timezone support for front matter dates without one b30b876bb Localize time.Format 950fdab90 Fix AddDate documentation 78d7b52b6 Document config.cascade fd1e1e4b7 Fix grammar and spelling (#1497) 05bf3aa32 Fix grammar / typos in news 32060a3b4 One more try f6e24ddfa PNG to JPG for the rel notes image 9ec5bdfad Update index.md 5f5d7f69d Release Hugo 0.86.0 2dd60bb71 releaser: Add release notes to /docs for release of 0.86.0 6445fb36c Merge commit '53a352795a69a9d4a373f50ec62138595948c6ea' cb57ca73a Simplify "active menu" logic for section menus git-subtree-dir: docs git-subtree-split: 327003421d8c07f9764aaaf644626805287fd30c
4 KiB
4 KiB
title | linktitle | description | date | publishdate | lastmod | categories | keywords | draft | menu | weight | sections_weight | aliases | toc | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Menu Entry Properties | Menu Entry Properties | A menu entry in a menu-template has specific variables and functions to make menu management easier. | 2017-03-12 | 2017-03-12 | 2017-03-12 |
|
|
false |
|
50 | 50 |
|
false |
A menu entry has the following properties available that can be used in a menu template.
Menu Entry Variables
- .Menu
- string
Name of the menu that contains this menu entry. - .URL
- string
URL that the menu entry points to. Theurl
key, if set for the menu entry, sets this value. If that key is not set, and if the menu entry is set in a page front-matter, this value defaults to the page's.RelPermalink
. - .Page
- *Page
Reference to the page object associated with the menu entry. This will be non-nil if the menu entry is set via a page's front-matter and not via the site config. - .PageRef {{< new-in "0.86.0" >}}
- string
Can be set if defined in site config and the menu entry refers to a Page. site.GetPage will be used to do the page lookup. If this is set, you don't need to set theURL
. - .Name
- string
Name of the menu entry. Thename
key, if set for the menu entry, sets this value. If that key is not set, and if the menu entry is set in a page front-matter, this value defaults to the page's.LinkTitle
. - .Identifier
- string
Value of theidentifier
key if set for the menu entry. This value must be unique for each menu entry. It is necessary to set a unique identifier manually if two or more menu entries have the same.Name
. - .Pre
- template.HTML
Value of thepre
key if set for the menu entry. This value typically contains a string representing HTML. - .Post
- template.HTML
Value of thepost
key if set for the menu entry. This value typically contains a string representing HTML. - .Weight
- int
Value of theweight
key if set for the menu entry. By default the entries in a menu are sorted ascending by theirweight
. If that key is not set, and if the menu entry is set in a page front-matter, this value defaults to the page's.Weight
. - .Parent
- string
Name (or Identifier if present) of this menu entry's parent menu entry. Theparent
key, if set for the menu entry, sets this value. If this key is set, this menu entry nests under that parent entry, else it nests directly under the.Menu
. - .Children
- Menu
This value is auto-populated by Hugo. It is a collection of children menu entries, if any, under the current menu entry.
Menu Entry Functions
Menus also have the following functions available:
- .HasChildren
- boolean
Returnstrue
if.Children
is non-nil. - .KeyName
- string
Returns the.Identifier
if present, else returns the.Name
. - .IsEqual
- boolean
Returnstrue
if the two compared menu entries represent the same menu entry. - .IsSameResource
- boolean
Returnstrue
if the two compared menu entries have the same.URL
. - .Title
- string
Link title, meant to be used in thetitle
attribute of a menu entry's<a>
-tags. Returns the menu entry'stitle
key if set. Else, if the menu entry was created through a page's front-matter, it returns the page's.LinkTitle
. Else, it just returns an empty string.
Other Menu-related Functions
Additionally, here are some relevant methods available to menus on a page:
- .IsMenuCurrent
- (menu string, menuEntry *MenuEntry ) boolean
See.IsMenuCurrent
method. - .HasMenuCurrent
- (menu string, menuEntry *MenuEntry) boolean
See.HasMenuCurrent
method.