Debian Codegraph @

docs/content/en/methods/menu-entry/Parent.md

raw
1 ---
2 title: Parent
3 description: Returns the `parent` property of the given menu entry.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: string
9 signatures: [MENUENTRY.Parent]
10 ---
11
12 With this menu definition:
13
14 {{< code-toggle file=hugo >}}
15 [[menus.main]]
16 name = 'Products'
17 pageRef = '/product'
18 weight = 10
19
20 [[menus.main]]
21 name = 'Product 1'
22 pageRef = '/products/product-1'
23 parent = 'Products'
24 weight = 1
25
26 [[menus.main]]
27 name = 'Product 2'
28 pageRef = '/products/product-2'
29 parent = 'Products'
30 weight = 2
31 {{< /code-toggle >}}
32
33 This template renders the nested menu, listing the `parent` property next each of the child entries:
34
35 ```go-html-template
36 <ul>
37 {{ range .Site.Menus.main }}
38 <li>
39 <a href="{{ .URL }}">{{ .Name }}</a>
40 {{ if .HasChildren }}
41 <ul>
42 {{ range .Children }}
43 <li><a href="{{ .URL }}">{{ .Name }}</a> ({{ .Parent }})</li>
44 {{ end }}
45 </ul>
46 {{ end }}
47 </li>
48 {{ end }}
49 </ul>
50 ```