mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
@@ -7,8 +7,8 @@ menu:
|
||||
docs:
|
||||
parent: templates
|
||||
weight: 140
|
||||
toc: true
|
||||
weight: 140
|
||||
toc: true
|
||||
aliases: [/templates/menus/]
|
||||
---
|
||||
|
||||
@@ -28,7 +28,7 @@ The example below handles every combination.
|
||||
|
||||
This partial template recursively "walks" a menu structure, rendering a localized, accessible nested list.
|
||||
|
||||
{{< code file="layouts/partials/menu.html" >}}
|
||||
{{< code file=layouts/partials/menu.html copy=true >}}
|
||||
{{- $page := .page }}
|
||||
{{- $menuID := .menuID }}
|
||||
|
||||
@@ -75,7 +75,7 @@ This partial template recursively "walks" a menu structure, rendering a localize
|
||||
|
||||
Call the partial above, passing a menu ID and the current page in context.
|
||||
|
||||
{{< code file="layouts/_default/single.html" >}}
|
||||
{{< code file=layouts/_default/single.html >}}
|
||||
{{ partial "menu.html" (dict "menuID" "main" "page" .) }}
|
||||
{{ partial "menu.html" (dict "menuID" "footer" "page" .) }}
|
||||
{{< /code >}}
|
||||
@@ -86,7 +86,7 @@ Regardless of how you [define menu entries], an entry associated with a page has
|
||||
|
||||
This simplistic example renders a page parameter named `version` next to each entry's `name`. Code defensively using `with` or `if` to handle entries where (a) the entry points to an external resource, or (b) the `version` parameter is not defined.
|
||||
|
||||
{{< code file="layouts/_default/single.html" >}}
|
||||
{{< code file=layouts/_default/single.html >}}
|
||||
{{- range site.Menus.main }}
|
||||
<a href="{{ .URL }}">
|
||||
{{ .Name }}
|
||||
@@ -108,7 +108,7 @@ When you define menu entries [in site configuration] or [in front matter], you c
|
||||
|
||||
This simplistic example renders a `class` attribute for each anchor element. Code defensively using `with` or `if` to handle entries where `params.class` is not defined.
|
||||
|
||||
{{< code file="layouts/partials/menu.html" >}}
|
||||
{{< code file=layouts/partials/menu.html >}}
|
||||
{{- range site.Menus.main }}
|
||||
<a {{ with .Params.class -}} class="{{ . }}" {{ end -}} href="{{ .URL }}">
|
||||
{{ .Name }}
|
||||
@@ -128,5 +128,5 @@ Hugo provides two methods to localize your menu entries. See [multilingual].
|
||||
[localize the menu entries]: /content-management/multilingual/#menus
|
||||
[menu entry defined in front matter]: /content-management/menus/#example-front-matter
|
||||
[menu entry defined in site configuration]: /content-management/menus/#example-site-configuration
|
||||
[menu variables and methods]: /variables/menus/
|
||||
[menu variables and methods]: /variables/menu-entry/
|
||||
[multilingual]: /content-management/multilingual/#menus
|
||||
|
Reference in New Issue
Block a user