Use canonical key when documenting menu configs

This commit is contained in:
Joe Mooring
2023-12-09 08:53:26 -08:00
committed by Joe Mooring
parent 7d5a13d8db
commit 1f2e7b9b2c
17 changed files with 74 additions and 68 deletions
+23 -15
View File
@@ -48,7 +48,7 @@ To add a page to the "main" menu:
{{< code-toggle file=content/about.md fm=true >}}
title = 'About'
menu = 'main'
menus = 'main'
{{< /code-toggle >}}
Access the entry with `site.Menus.main` in your templates. See [menu templates] for details.
@@ -57,11 +57,15 @@ To add a page to the "main" and "footer" menus:
{{< code-toggle file=content/contact.md fm=true >}}
title = 'Contact'
menu = ['main','footer']
menus = ['main','footer']
{{< /code-toggle >}}
Access the entry with `site.Menus.main` and `site.Menus.footer` in your templates. See [menu templates] for details.
{{% note %}}
The configuration key in the examples above is `menus`. The `menu` (singular) configuration key is an alias for `menus`.
{{% /note %}}
### Properties {#properties-front-matter}
Use these properties when defining menu entries in front matter:
@@ -96,11 +100,11 @@ This front matter menu entry demonstrates some of the available properties:
{{< code-toggle file=content/products/software.md fm=true >}}
title = 'Software'
[menu.main]
[[menus.main]]
parent = 'Products'
weight = 20
pre = '<i class="fa-solid fa-code"></i>'
[menu.main.params]
[menus.main.params]
class = 'center'
{{< /code-toggle >}}
@@ -111,17 +115,17 @@ Access the entry with `site.Menus.main` in your templates. See [menu templates]
To define entries for the "main" menu:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Home'
pageRef = '/'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Products'
pageRef = '/products'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Services'
pageRef = '/services'
weight = 30
@@ -132,12 +136,12 @@ This creates a menu structure that you can access with `site.Menus.main` in your
To define entries for the "footer" menu:
{{< code-toggle file=hugo >}}
[[menu.footer]]
[[menus.footer]]
name = 'Terms'
pageRef = '/terms'
weight = 10
[[menu.footer]]
[[menus.footer]]
name = 'Privacy'
pageRef = '/privacy'
weight = 20
@@ -145,6 +149,10 @@ weight = 20
This creates a menu structure that you can access with `site.Menus.footer` in your templates. See [menu templates] for details.
{{% note %}}
The configuration key in the examples above is `menus`. The `menu` (singular) configuration key is an alias for `menus`.
{{% /note %}}
### Properties {#properties-site-configuration}
{{% note %}}
@@ -177,34 +185,34 @@ url
This nested menu demonstrates some of the available properties:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Products'
pageRef = '/products'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Hardware'
pageRef = '/products/hardware'
parent = 'Products'
weight = 1
[[menu.main]]
[[menus.main]]
name = 'Software'
pageRef = '/products/software'
parent = 'Products'
weight = 2
[[menu.main]]
[[menus.main]]
name = 'Services'
pageRef = '/services'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Hugo'
pre = '<i class="fa fa-heart"></i>'
url = 'https://gohugo.io/'
weight = 30
[menu.main.params]
[menus.main.params]
rel = 'external'
{{< /code-toggle >}}
+10 -11
View File
@@ -546,12 +546,12 @@ languageCode = 'de-DE'
languageName = 'Deutsch'
weight = 1
[[languages.de.menu.main]]
[[languages.de.menus.main]]
name = 'Produkte'
pageRef = '/products'
weight = 10
[[languages.de.menu.main]]
[[languages.de.menus.main]]
name = 'Leistungen'
pageRef = '/services'
weight = 20
@@ -561,12 +561,12 @@ languageCode = 'en-US'
languageName = 'English'
weight = 2
[[languages.en.menu.main]]
[[languages.en.menus.main]]
name = 'Products'
pageRef = '/products'
weight = 10
[[languages.en.menu.main]]
[[languages.en.menus.main]]
name = 'Services'
pageRef = '/services'
weight = 20
@@ -579,13 +579,12 @@ With a more complex menu structure, create a [configuration directory] and split
```text
config/
└── _default/
├── menus/
├── menu.de.toml
│ └── menu.en.toml
├── menus.de.toml
├── menus.en.toml
└── hugo.toml
```
{{< code-toggle file=config/_default/menus/menu.de >}}
{{< code-toggle file=config/_default/menus.de >}}
[[main]]
name = 'Produkte'
pageRef = '/products'
@@ -596,7 +595,7 @@ pageRef = '/services'
weight = 20
{{< /code-toggle >}}
{{< code-toggle file=config/_default/menus/menu.en >}}
{{< code-toggle file=config/_default/menus.en >}}
[[main]]
name = 'Products'
pageRef = '/products'
@@ -627,12 +626,12 @@ The `identifier` depends on how you define menu entries:
For example, if you define menu entries in site configuration:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
identifier = 'products'
name = 'Products'
pageRef = '/products'
weight = 10
[[menu.main]]
[[menus.main]]
identifier = 'services'
name = 'Services'
pageRef = '/services'
+1 -1
View File
@@ -19,7 +19,7 @@ aliases: [/functions/safehtmlattr]
Given a site configuration that contains this menu entry:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = "IRC"
url = "irc://irc.freenode.net/#golang"
{{< /code-toggle >}}
+1 -1
View File
@@ -23,7 +23,7 @@ Without `safeURL`, only the URI schemes `http:`, `https:` and `mailto:` are cons
The following examples use a [site `hugo.toml`][configuration] with the following [menu entry][menus]:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = "IRC: #golang at freenode"
url = "irc://irc.freenode.net/#golang"
{{< /code-toggle >}}
+3 -3
View File
@@ -15,18 +15,18 @@ Use the `Children` method when rendering a nested menu.
With this site configuration:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Products'
pageRef = '/product'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Product 1'
pageRef = '/products/product-1'
parent = 'Products'
weight = 1
[[menu.main]]
[[menus.main]]
name = 'Product 2'
pageRef = '/products/product-2'
parent = 'Products'
+3 -3
View File
@@ -15,18 +15,18 @@ Use the `HasChildren` method when rendering a nested menu.
With this site configuration:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Products'
pageRef = '/product'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Product 1'
pageRef = '/products/product-1'
parent = 'Products'
weight = 1
[[menu.main]]
[[menus.main]]
name = 'Product 2'
pageRef = '/products/product-2'
parent = 'Products'
+2 -2
View File
@@ -14,13 +14,13 @@ The `Identifier` method returns the `identifier` property of the menu entry. If
[automatically]: /content-management/menus/#define-automatically
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
identifier = 'about'
name = 'About'
pageRef = '/about'
weight = 10
[[menu.main]]
[[menus.main]]
identifier = 'contact'
name = 'Contact'
pageRef = '/contact'
+2 -2
View File
@@ -12,13 +12,13 @@ action:
In this menu definition, the second entry does not contain an `identifier`, so the `Identifier` method returns its `name` property instead:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
identifier = 'about'
name = 'About'
pageRef = '/about'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Contact'
pageRef = '/contact'
weight = 20
+3 -3
View File
@@ -14,15 +14,15 @@ Regardless of how you [define menu entries], an entry associated with a page has
In this menu definition, the first two entries are associated with a page, the last entry is not:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
pageRef = '/about'
weight = 10
[[menu.main]]
[[menus.main]]
pageRef = '/contact'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Hugo'
url = 'https://gohugo.io'
weight = 30
+4 -4
View File
@@ -12,21 +12,21 @@ action:
When you define menu entries [in site configuration] or [in front matter], you can include a `params` key to attach additional information to the entry. For example:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'About'
pageRef = '/about'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Contact'
pageRef = '/contact'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Hugo'
url = 'https://gohugo.io'
weight = 30
[menu.main.params]
[menus.main.params]
rel = 'external'
{{< /code-toggle >}}
+3 -4
View File
@@ -12,19 +12,18 @@ action:
With this menu definition:
{{< code-toggle file=hugo >}}
[menu]
[[menu.main]]
[[menus.main]]
name = 'Products'
pageRef = '/product'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Product 1'
pageRef = '/products/product-1'
parent = 'Products'
weight = 1
[[menu.main]]
[[menus.main]]
name = 'Product 2'
pageRef = '/products/product-2'
parent = 'Products'
@@ -7,14 +7,14 @@ In this site configuration we enable rendering of [emoji shortcodes], and add em
{{< code-toggle file=hugo >}}
enableEmoji = true
[[menu.main]]
[[menus.main]]
name = 'About'
pageRef = '/about'
post = ':point_left:'
pre = ':point_right:'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Contact'
pageRef = '/contact'
post = ':arrow_left:'
+3 -3
View File
@@ -14,17 +14,17 @@ The `Sort` method returns the given menu with its entries sorted by `name`.
Consider this menu definition:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Services'
pageRef = '/services'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'About'
pageRef = '/about'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Contact'
pageRef = '/contact'
weight = 30
+3 -3
View File
@@ -16,19 +16,19 @@ The `ByWeight` method returns the given menu with its entries sorted by [`weight
Consider this menu definition:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
identifier = 'about'
name = 'About'
pageRef = '/about'
weight = 20
[[menu.main]]
[[menus.main]]
identifier = 'services'
name = 'Services'
pageRef = '/services'
weight = 10
[[menu.main]]
[[menus.main]]
identifier = 'contact'
name = 'Contact'
pageRef = '/contact'
+3 -3
View File
@@ -14,17 +14,17 @@ The `Limit` method returns the given menu, limited to the first N entries.
Consider this menu definition:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Services'
pageRef = '/services'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'About'
pageRef = '/about'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Contact'
pageRef = '/contact'
weight = 30
+3 -3
View File
@@ -14,17 +14,17 @@ The `Reverse` method returns the given menu, reversing the sort order of its ent
Consider this menu definition:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Services'
pageRef = '/services'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'About'
pageRef = '/about'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Contact'
pageRef = '/contact'
weight = 30
+5 -5
View File
@@ -22,27 +22,27 @@ Menus can be defined and localized in several ways. Please see the [menus] secti
A site can have multiple menus. For example, a main menu and a footer menu:
{{< code-toggle file=hugo >}}
[[menu.main]]
[[menus.main]]
name = 'Home'
pageRef = '/'
weight = 10
[[menu.main]]
[[menus.main]]
name = 'Books'
pageRef = '/books'
weight = 20
[[menu.main]]
[[menus.main]]
name = 'Films'
pageRef = '/films'
weight = 30
[[menu.footer]]
[[menus.footer]]
name = 'Legal'
pageRef = '/legal'
weight = 10
[[menu.footer]]
[[menus.footer]]
name = 'Privacy'
pageRef = '/privacy'
weight = 20