Skip to content

Commit

Permalink
Use canonical key when documenting menu configs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring committed Dec 12, 2023
1 parent 7d5a13d commit 1f2e7b9
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 68 deletions.
38 changes: 23 additions & 15 deletions content/en/content-management/menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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 >}}

Expand All @@ -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
Expand All @@ -132,19 +136,23 @@ 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
{{< /code-toggle >}}

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 %}}
Expand Down Expand Up @@ -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 >}}

Expand Down
21 changes: 10 additions & 11 deletions content/en/content-management/multilingual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/safe/HTMLAttr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}
Expand Down
2 changes: 1 addition & 1 deletion content/en/functions/safe/URL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}
Expand Down
6 changes: 3 additions & 3 deletions content/en/methods/menu-entry/Children.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions content/en/methods/menu-entry/HasChildren.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions content/en/methods/menu-entry/Identifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions content/en/methods/menu-entry/KeyName.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions content/en/methods/menu-entry/Page.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions content/en/methods/menu-entry/Params.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 >}}

Expand Down
7 changes: 3 additions & 4 deletions content/en/methods/menu-entry/Parent.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions content/en/methods/menu-entry/_common/pre-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:'
Expand Down
6 changes: 3 additions & 3 deletions content/en/methods/menu/ByName.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 1f2e7b9

Please sign in to comment.