Debian Codegraph @

docs/content/en/methods/menu-entry/Identifier.md

raw
1 ---
2 title: Identifier
3 description: Returns the `identifier` property of the given menu entry.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: string
9 signatures: [MENUENTRY.Identifier]
10 ---
11
12 The `Identifier` method returns the `identifier` property of the menu entry. If you define the menu entry [automatically][], it returns the page's section.
13
14 {{< code-toggle file=hugo >}}
15 [[menus.main]]
16 identifier = 'about'
17 name = 'About'
18 pageRef = '/about'
19 weight = 10
20
21 [[menus.main]]
22 identifier = 'contact'
23 name = 'Contact'
24 pageRef = '/contact'
25 weight = 20
26 {{< /code-toggle >}}
27
28 This example uses the `Identifier` method when querying the translation table on a multilingual project, falling back the `name` property if a matching key in the translation table does not exist:
29
30 ```go-html-template
31 <ul>
32 {{ range .Site.Menus.main }}
33 <li><a href="{{ .URL }}">{{ or (T .Identifier) .Name }}</a></li>
34 {{ end }}
35 </ul>
36 ```
37
38 > [!NOTE]
39 > In the menu definition above, note that the `identifier` property is only required when two or more menu entries have the same name, or when localizing the name using translation tables.
40
41 [automatically]: /content-management/menus/#define-automatically