diff options
Diffstat (limited to 'docs/content/en/templates')
-rw-r--r-- | docs/content/en/templates/menu-templates.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/content/en/templates/menu-templates.md b/docs/content/en/templates/menu-templates.md index b39fe42a9..8893d7b5a 100644 --- a/docs/content/en/templates/menu-templates.md +++ b/docs/content/en/templates/menu-templates.md @@ -160,3 +160,23 @@ Here's an example: {{ end }} </nav> ``` + +## Using .Params in Menus + +User-defined content on menu items are accessible via `.Params`. + +Here's an example: + +``` +<nav class="sidebar-nav"> + {{ range .Site.Menus.main }} + <a href="{{ .URL }}" title="{{ .Title }}" class="{{ with .Params.class }}{{ . }}{{ end }}"> + {{- .Name -}} + </a> + {{ end }} +</nav> +``` + +{{% note %}} +With Menu-level .Params they can easily exist on one menu item but not another. It's recommended to access them gracefully using the [with function](/functions/with). +{{% /note %}}
\ No newline at end of file |