- About Hugo
- Getting Started
- Hugo Modules
-
Content Management
- Content Management Overview
- Organization
- Page Bundles
- Content Formats
- Front Matter
- Build Options
- Page Resources
- Image Processing
- Shortcodes
- Related Content
- Sections
- Content Types
- Archetypes
- Taxonomies
- Summaries
- Links and Cross References
- URL Management
- Menus
- Static Files
- Table of Contents
- Comments
- Multilingual and i18n
- Syntax Highlighting
-
Templates
- Templates Overview
- Introduction
- Template Lookup Order
- Custom Output Formats
- Base Templates and Blocks
- List Page Templates
- Homepage Template
- Section Templates
- Taxonomy Templates
- Single Page Templates
- Content View Templates
- Data Templates
- Partial Templates
- Shortcode Templates
- Local File Templates
- 404 Page
- Menu Templates
- Pagination
- RSS Templates
- Sitemap Template
- Robots.txt
- Internal Templates
- Alternative Templating
- Template Debugging
-
Functions
- Functions Quick Reference
- .AddDate
- .Format
- .Get
- .GetPage
- .HasMenuCurrent
- .IsMenuCurrent
- .Param
- .Render
- .RenderString
- .Scratch
- .Unix
- absLangURL
- absURL
- after
- anchorize
- append
- apply
- base64
- chomp
- complement
- cond
- countrunes
- countwords
- dateFormat
- default
- delimit
- dict
- echoParam
- emojify
- eq
- errorf and warnf
- fileExists
- findRE
- first
- float
- ge
- getenv
- group
- gt
- hasPrefix
- highlight
- hmac
- htmlEscape
- htmlUnescape
- hugo
- humanize
- i18n
- Image Functions
- in
- index
- int
- intersect
- isset
- jsonify
- lang.Merge
- lang.NumFmt
- last
- le
- len
- lower
- lt
- markdownify
- Math
- md5
- merge
- ne
- now
- os.Stat
- partialCached
- path.Base
- path.Dir
- path.Ext
- path.Join
- path.Split
- plainify
- pluralize
- printf
- println
- querify
- range
- readDir
- readFile
- ref
- reflect.IsMap
- reflect.IsSlice
- relLangURL
- relref
- relURL
- replace
- replaceRE
- safeCSS
- safeHTML
- safeHTMLAttr
- safeJS
- safeURL
- seq
- sha
- shuffle
- singularize
- site
- slice
- slicestr
- sort
- split
- string
- strings.Count
- strings.HasSuffix
- strings.Repeat
- strings.RuneCount
- strings.TrimLeft
- strings.TrimPrefix
- strings.TrimRight
- strings.TrimSuffix
- substr
- symdiff
- templates.Exists
- time
- title
- transform.Unmarshal
- trim
- truncate
- union
- uniq
- upper
- urlize
- urls.Parse
- where
- with
- Variables
- Hugo Pipes
- CLI
- Troubleshooting
- Tools
- Hosting & Deployment
- Contribute
- Maintenance
Menu Entry Properties
A menu entry in a menu-template has specific variables and functions to make menu management easier.
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. The
urlkey, 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.
- .Name
- string
Name of the menu entry. The
namekey, 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 the
identifierkey 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 the
prekey if set for the menu entry. This value typically contains a string representing HTML. - .Post
- template.HTML
Value of the
postkey if set for the menu entry. This value typically contains a string representing HTML. - .Weight
- int
Value of the
weightkey 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. The
parentkey, 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
Returns
trueif.Childrenis non-nil. - .KeyName
- string
Returns the
.Identifierif present, else returns the.Name. - .IsEqual
- boolean
Returns
trueif the two compared menu entries represent the same menu entry. - .IsSameResource
- boolean
Returns
trueif the two compared menu entries have the same.URL. - .Title
- string
Link title, meant to be used in the
titleattribute of a menu entry’s<a>-tags. Returns the menu entry’stitlekey 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
.IsMenuCurrentmethod . - .HasMenuCurrent
- (menu string, menuEntry *MenuEntry) boolean
See
.HasMenuCurrentmethod .