Identifier
Syntax
MENUENTRY.Identifier
Returns
string
The Identifier method returns the identifier property of the menu entry. If you define the menu entry automatically, it returns the page’s section.
hugo.
 
 
 
menus:
  main:
  - identifier: about
    name: About
    pageRef: /about
    weight: 10
  - identifier: contact
    name: Contact
    pageRef: /contact
    weight: 20
[menus]
  [[menus.main]]
    identifier = 'about'
    name = 'About'
    pageRef = '/about'
    weight = 10
  [[menus.main]]
    identifier = 'contact'
    name = 'Contact'
    pageRef = '/contact'
    weight = 20
{
   "menus": {
      "main": [
         {
            "identifier": "about",
            "name": "About",
            "pageRef": "/about",
            "weight": 10
         },
         {
            "identifier": "contact",
            "name": "Contact",
            "pageRef": "/contact",
            "weight": 20
         }
      ]
   }
}
This example uses the Identifier method when querying the translation table on a multilingual site, falling back the name property if a matching key in the translation table does not exist:
<ul>
  {{ range .Site.Menus.main }}
    <li><a href="{{ .URL }}">{{ or (T .Identifier) .Name }}</a></li>
  {{ end }}
</ul>