summaryrefslogtreecommitdiffstats
path: root/docs/content/en/methods/menu-entry/Identifier.md
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-12-04 15:24:01 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-12-04 15:24:01 +0100
commitd19ed4d4e69f51873135f05a51831d25ecc2071e (patch)
tree74dfd9af2b0f4a6c0933266c50ceaa569d388c71 /docs/content/en/methods/menu-entry/Identifier.md
parent9f978d387f8b7cb6bc03fe6b4dd52bb16862a784 (diff)
parent35dec7c96f7ee3eb17dd444f7067f0c776fb56ae (diff)
downloadhugo-d19ed4d4e69f51873135f05a51831d25ecc2071e.tar.gz
hugo-d19ed4d4e69f51873135f05a51831d25ecc2071e.zip
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
Diffstat (limited to 'docs/content/en/methods/menu-entry/Identifier.md')
-rw-r--r--docs/content/en/methods/menu-entry/Identifier.md44
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..a4d7e129e
--- /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 >}}
+[[menu.main]]
+identifier = 'about'
+name = 'About'
+pageRef = '/about'
+weight = 10
+
+[[menu.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 %}}