Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Jones <david@davidejones.com>2020-11-23 00:09:59 +0300
committerGitHub <noreply@github.com>2020-11-23 00:09:59 +0300
commit8f5c9a747fcebb02bb99f5de272046411eb15370 (patch)
treeda9d219c001c2ddccafe8f5c5d05d962bf8c6275 /docs/content/en/templates
parente4fcb672ed8bae21fd9780292b54fea3040dd877 (diff)
Add menu params
Fixes #7951
Diffstat (limited to 'docs/content/en/templates')
-rw-r--r--docs/content/en/templates/menu-templates.md20
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