diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-01-27 10:48:33 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-01-27 10:48:57 +0100 |
commit | 5fd1e7490305570872d3899f5edda950903c5213 (patch) | |
tree | f0cdc490a0942d720494c0044a64c6397d1ab6a5 /docs/content/en/methods/menu-entry/Identifier.md | |
parent | fc7de7136acbcf0aef54ae8460c7702bc83709be (diff) | |
parent | 9b0050e9aabe4be65c78ccf292a348f309d50ccd (diff) | |
download | hugo-5fd1e7490305570872d3899f5edda950903c5213.tar.gz hugo-5fd1e7490305570872d3899f5edda950903c5213.zip |
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```
Closes #11925
Diffstat (limited to 'docs/content/en/methods/menu-entry/Identifier.md')
-rw-r--r-- | docs/content/en/methods/menu-entry/Identifier.md | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/docs/content/en/methods/menu-entry/Identifier.md b/docs/content/en/methods/menu-entry/Identifier.md new file mode 100644 index 000000000..ba8b77ece --- /dev/null +++ b/docs/content/en/methods/menu-entry/Identifier.md @@ -0,0 +1,44 @@ +--- +title: Identifier +description: Returns the `identifier` property of the given menu entry. +categories: [] +keywords: [] +action: + related: [] + returnType: string + signatures: [MENUENTRY.Identifier] +--- + +The `Identifier` method returns the `identifier` property of the menu entry. If you define the menu entry [automatically], it returns the page's section. + +[automatically]: /content-management/menus/#define-automatically + +{{< code-toggle file=hugo >}} +[[menus.main]] +identifier = 'about' +name = 'About' +pageRef = '/about' +weight = 10 + +[[menus.main]] +identifier = 'contact' +name = 'Contact' +pageRef = '/contact' +weight = 20 +{{< /code-toggle >}} + +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: + +```go-html-template +<ul> + {{ range .Site.Menus.main }} + <li><a href="{{ .URL }}">{{ or (T .Identifier) .Name }}</a></li> + {{ end }} +</ul> +``` + +{{% note %}} +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. + +[details]: /content-management/menus/#properties-front-matter +{{% /note %}} |