<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Menu entry methods on Hugo</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/</link><description>Recent content in Menu entry methods on Hugo</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/index.xml" rel="self" type="application/rss+xml"/><item><title>Children</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/children/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/children/</guid><description>Use the Children method when rendering a nested menu.
With this site configuration:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; menus: main: - name: Products pageRef: /product weight: 10 - name: Product 1 pageRef: /products/product-1 parent: Products weight: 1 - name: Product 2 pageRef: /products/product-2 parent: Products weight: 2 [menus] [[menus.main]] name = &amp;#39;Products&amp;#39; pageRef = &amp;#39;/product&amp;#39; weight = 10 [[menus.main]] name = &amp;#39;Product 1&amp;#39; pageRef = &amp;#39;/products/product-1&amp;#39; parent = &amp;#39;Products&amp;#39; weight = 1 [[menus.</description></item><item><title>HasChildren</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/haschildren/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/haschildren/</guid><description>Use the HasChildren method when rendering a nested menu.
With this site configuration:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; menus: main: - name: Products pageRef: /product weight: 10 - name: Product 1 pageRef: /products/product-1 parent: Products weight: 1 - name: Product 2 pageRef: /products/product-2 parent: Products weight: 2 [menus] [[menus.main]] name = &amp;#39;Products&amp;#39; pageRef = &amp;#39;/product&amp;#39; weight = 10 [[menus.main]] name = &amp;#39;Product 1&amp;#39; pageRef = &amp;#39;/products/product-1&amp;#39; parent = &amp;#39;Products&amp;#39; weight = 1 [[menus.</description></item><item><title>Identifier</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/identifier/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/identifier/</guid><description>The Identifier method returns the identifier property of the menu entry. If you define the menu entry automatically, it returns the page&amp;rsquo;s section.
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; menus: main: - identifier: about name: About pageRef: /about weight: 10 - identifier: contact name: Contact pageRef: /contact weight: 20 [menus] [[menus.main]] identifier = &amp;#39;about&amp;#39; name = &amp;#39;About&amp;#39; pageRef = &amp;#39;/about&amp;#39; weight = 10 [[menus.main]] identifier = &amp;#39;contact&amp;#39; name = &amp;#39;Contact&amp;#39; pageRef = &amp;#39;/contact&amp;#39; weight = 20 { &amp;#34;menus&amp;#34;: { &amp;#34;main&amp;#34;: [ { &amp;#34;identifier&amp;#34;: &amp;#34;about&amp;#34;, &amp;#34;name&amp;#34;: &amp;#34;About&amp;#34;, &amp;#34;pageRef&amp;#34;: &amp;#34;/about&amp;#34;, &amp;#34;weight&amp;#34;: 10 }, { &amp;#34;identifier&amp;#34;: &amp;#34;contact&amp;#34;, &amp;#34;name&amp;#34;: &amp;#34;Contact&amp;#34;, &amp;#34;pageRef&amp;#34;: &amp;#34;/contact&amp;#34;, &amp;#34;weight&amp;#34;: 20 } ] } } This example uses the Identifier method when querying the translation table on a multilingual site, falling back the name property if a matching key in the translation table does not exist:</description></item><item><title>KeyName</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/keyname/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/keyname/</guid><description>In this menu definition, the second entry does not contain an identifier, so the Identifier method returns its name property instead:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; menus: main: - identifier: about name: About pageRef: /about weight: 10 - name: Contact pageRef: /contact weight: 20 [menus] [[menus.main]] identifier = &amp;#39;about&amp;#39; name = &amp;#39;About&amp;#39; pageRef = &amp;#39;/about&amp;#39; weight = 10 [[menus.main]] name = &amp;#39;Contact&amp;#39; pageRef = &amp;#39;/contact&amp;#39; weight = 20 { &amp;#34;menus&amp;#34;: { &amp;#34;main&amp;#34;: [ { &amp;#34;identifier&amp;#34;: &amp;#34;about&amp;#34;, &amp;#34;name&amp;#34;: &amp;#34;About&amp;#34;, &amp;#34;pageRef&amp;#34;: &amp;#34;/about&amp;#34;, &amp;#34;weight&amp;#34;: 10 }, { &amp;#34;name&amp;#34;: &amp;#34;Contact&amp;#34;, &amp;#34;pageRef&amp;#34;: &amp;#34;/contact&amp;#34;, &amp;#34;weight&amp;#34;: 20 } ] } } This example uses the KeyName method when querying the translation table on a multilingual site, falling back the name property if a matching key in the translation table does not exist:</description></item><item><title>Menu</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/menu/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/menu/</guid><description>{{ range .Site.Menus.main }} {{ .Menu }} → main {{ end }} Use this method with the IsMenuCurrent and HasMenuCurrent methods on a Page object to set &amp;ldquo;active&amp;rdquo; and &amp;ldquo;ancestor&amp;rdquo; classes on a rendered entry. See this example.</description></item><item><title>Name</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/name/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/name/</guid><description>If you define the menu entry automatically, the Name method returns the page’s LinkTitle, falling back to its Title.
If you define the menu entry in front matter or in site configuration, the Name method returns the name property, falling back to the page’s LinkTitle, then to its Title.
&amp;lt;ul&amp;gt; {{ range .Site.Menus.main }} &amp;lt;li&amp;gt;&amp;lt;a href=&amp;#34;{{ .URL }}&amp;#34;&amp;gt;{{ .Name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; {{ end }} &amp;lt;/ul&amp;gt;</description></item><item><title>Page</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/page/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/page/</guid><description>Regardless of how you define menu entries, an entry associated with a page has access to its methods.
In this menu definition, the first two entries are associated with a page, the last entry is not:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; menus: main: - pageRef: /about weight: 10 - pageRef: /contact weight: 20 - name: Hugo url: https://gohugo.io weight: 30 [menus] [[menus.main]] pageRef = &amp;#39;/about&amp;#39; weight = 10 [[menus.</description></item><item><title>Params</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/params/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/params/</guid><description>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:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; menus: main: - name: About pageRef: /about weight: 10 - name: Contact pageRef: /contact weight: 20 - name: Hugo params: rel: external url: https://gohugo.io weight: 30 [menus] [[menus.main]] name = &amp;#39;About&amp;#39; pageRef = &amp;#39;/about&amp;#39; weight = 10 [[menus.</description></item><item><title>Parent</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/parent/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/parent/</guid><description>With this menu definition:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; menus: main: - name: Products pageRef: /product weight: 10 - name: Product 1 pageRef: /products/product-1 parent: Products weight: 1 - name: Product 2 pageRef: /products/product-2 parent: Products weight: 2 [menus] [[menus.main]] name = &amp;#39;Products&amp;#39; pageRef = &amp;#39;/product&amp;#39; weight = 10 [[menus.main]] name = &amp;#39;Product 1&amp;#39; pageRef = &amp;#39;/products/product-1&amp;#39; parent = &amp;#39;Products&amp;#39; weight = 1 [[menus.main]] name = &amp;#39;Product 2&amp;#39; pageRef = &amp;#39;/products/product-2&amp;#39; parent = &amp;#39;Products&amp;#39; weight = 2 { &amp;#34;menus&amp;#34;: { &amp;#34;main&amp;#34;: [ { &amp;#34;name&amp;#34;: &amp;#34;Products&amp;#34;, &amp;#34;pageRef&amp;#34;: &amp;#34;/product&amp;#34;, &amp;#34;weight&amp;#34;: 10 }, { &amp;#34;name&amp;#34;: &amp;#34;Product 1&amp;#34;, &amp;#34;pageRef&amp;#34;: &amp;#34;/products/product-1&amp;#34;, &amp;#34;parent&amp;#34;: &amp;#34;Products&amp;#34;, &amp;#34;weight&amp;#34;: 1 }, { &amp;#34;name&amp;#34;: &amp;#34;Product 2&amp;#34;, &amp;#34;pageRef&amp;#34;: &amp;#34;/products/product-2&amp;#34;, &amp;#34;parent&amp;#34;: &amp;#34;Products&amp;#34;, &amp;#34;weight&amp;#34;: 2 } ] } } This template renders the nested menu, listing the parent property next each of the child entries:</description></item><item><title>Post</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/post/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/post/</guid><description>In this site configuration we enable rendering of emoji shortcodes, and add emoji shortcodes before (pre) and after (post) each menu entry:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; enableEmoji: true menus: main: - name: About pageRef: /about post: &amp;#39;:point_left:&amp;#39; pre: &amp;#39;:point_right:&amp;#39; weight: 10 - name: Contact pageRef: /contact post: &amp;#39;:arrow_left:&amp;#39; pre: &amp;#39;:arrow_right:&amp;#39; weight: 20 enableEmoji = true [menus] [[menus.main]] name = &amp;#39;About&amp;#39; pageRef = &amp;#39;/about&amp;#39; post = &amp;#39;:point_left:&amp;#39; pre = &amp;#39;:point_right:&amp;#39; weight = 10 [[menus.</description></item><item><title>Pre</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/pre/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/pre/</guid><description>In this site configuration we enable rendering of emoji shortcodes, and add emoji shortcodes before (pre) and after (post) each menu entry:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; enableEmoji: true menus: main: - name: About pageRef: /about post: &amp;#39;:point_left:&amp;#39; pre: &amp;#39;:point_right:&amp;#39; weight: 10 - name: Contact pageRef: /contact post: &amp;#39;:arrow_left:&amp;#39; pre: &amp;#39;:arrow_right:&amp;#39; weight: 20 enableEmoji = true [menus] [[menus.main]] name = &amp;#39;About&amp;#39; pageRef = &amp;#39;/about&amp;#39; post = &amp;#39;:point_left:&amp;#39; pre = &amp;#39;:point_right:&amp;#39; weight = 10 [[menus.</description></item><item><title>Title</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/title/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/title/</guid><description>If you define the menu entry automatically, the Title method returns the page’s LinkTitle, falling back to its Title.
If you define the menu entry in front matter or in site configuration, the Name method returns the title property, falling back to the page’s LinkTitle, then to its Title.
&amp;lt;ul&amp;gt; {{ range .Site.Menus.main }} &amp;lt;li&amp;gt;&amp;lt;a href=&amp;#34;{{ .URL }}&amp;#34;&amp;gt;{{ .Title }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; {{ end }} &amp;lt;/ul&amp;gt;</description></item><item><title>URL</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/url/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/url/</guid><description>For menu entries associated with a page, the URL method returns the page&amp;rsquo;s RelPermalink, otherwise it returns the entry&amp;rsquo;s url property.
&amp;lt;ul&amp;gt; {{ range .Site.Menus.main }} &amp;lt;li&amp;gt;&amp;lt;a href=&amp;#34;{{ .URL }}&amp;#34;&amp;gt;{{ .Name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; {{ end }} &amp;lt;/ul&amp;gt;</description></item><item><title>Weight</title><link>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/weight/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/menu-entry/weight/</guid><description>If you define the menu entry automatically, the Weight method returns the page’s Weight.
If you define the menu entry in front matter or in site configuration, the Weight method returns the weight property, falling back to the page’s Weight.
In this contrived example, we limit the number of menu entries based on weight:
&amp;lt;ul&amp;gt; {{ range .Site.Menus.main }} {{ if le .Weight 42 }} &amp;lt;li&amp;gt;&amp;lt;a href=&amp;#34;{{ .URL }}&amp;#34;&amp;gt;{{ .Name }}&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt; {{ end }} {{ end }} &amp;lt;/ul&amp;gt;</description></item></channel></rss>