mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
1.3 KiB
1.3 KiB
title | description | categories | keywords | action | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Params | Returns the `params` property of the given menu entry. |
|
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 name = 'About' pageRef = '/about' weight = 10
menu.main name = 'Contact' pageRef = '/contact' weight = 20
menu.main name = 'Hugo' url = 'https://gohugo.io' weight = 30 [menu.main.params] rel = 'external' {{< /code-toggle >}}
With this template:
<ul>
{{ range .Site.Menus.main }}
<li>
<a href="{{ .URL }}" {{ with .Params.rel }}rel="{{ . }}"{{ end }}>
{{ .Name }}
</a>
</li>
{{ end }}
</ul>
Hugo renders:
<ul>
<li><a href="/about/">About</a></li>
<li><a href="/contact/">Contact</a></li>
<li><a href="https://gohugo.io" rel="external">Hugo</a></li>
</ul>
See the menu templates section for more information.