I use hugo theme academic.
I create some content which type is docs.
There is a sidebar in left of page.
I want to sort these docs pages so I set weight.
But they are not sorted.
The patials/docs_sidebar.html is :
{{ $current_page := . }}
{{ $menu_name := (path.Base (path.Split .Path).Dir) }}
{{ with (index .Site.Menus $menu_name) }}
{{ else }}
{{ errorf "Please define menu items named `[menu.%s]` in your %s front matter or define `[[menu.%s]]` in `config.toml`." $menu_name .Path $menu_name }}
{{ end }}
{{(path.Base (path.Split .Path).Dir)}}
{{index (index $.Site.Menus $menu_name) 2}}
<form class="docs-search d-flex align-items-center">
<button class="btn docs-toggle d-md-none p-0 mr-3" type="button" data-toggle="collapse" data-target="#docs-nav" aria-controls="docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
<span><i class="fas fa-bars"></i></span>
</button>
{{ if eq $.Site.Params.search.engine 1 }}
<input name="q" type="search" class="form-control" id="search-query" placeholder="{{ i18n "search_placeholder" }}" autocomplete="off">
{{ end }}
</form>
<nav class="collapse docs-links" id="docs-nav">
{{ with (index .Site.Menus $menu_name) }}
{{ range (index $.Site.Menus $menu_name).ByWeight }}
<div class="docs-toc-item{{ if $current_page.IsMenuCurrent $menu_name . }} active{{ end }}">
<a class="docs-toc-link" {{ if .URL }}href="{{ .URL }}"{{else if .HasChildren }}href="{{ (index .Children 0).URL }}"{{end}}>{{ .Name }}{{.Parent}}</a>
{{- if .HasChildren }}
<ul class="nav docs-sidenav">
{{ range .Children }}
<li {{ if $current_page.IsMenuCurrent $menu_name . }}class="active"{{ end }}>
<a href="{{ .URL }}">{{ .Parent }}</a>
</li>
{{ end }}
</ul>
{{ end }}
</div>
{{ end }}
{{ end }}
</nav>
I want to sort like this:
├── Overview
├── Parent2
│ ├── Children3
│ └── Children4
└── Parent1
├── Children1
└── Children2
But actually like this:
├── Overview
├── Parent1
│ ├── Children1
│ └── Children2
└── Parent2
├── Children1
└── Children2
I set weight like this:
tutorial/_index.md
[menu.tuts2]
name = "Overview"
weight = 1
tutorial/children1.md
linktitle = "Children1"
[menu.tuts2]
parent = "Parent1"
weight = 4
tutorial/chindren2。.md
linktitle = "Children2"
[menu.tuts2]
parent = "Parent1"
weight = 5
tutorial/children3.md
linktitle = "Children3"
[menu.tuts2]
parent = "Parent2"
weight = 2
tutorial/children4.md
linktitle = "Children4"
[menu.tuts2]
parent = "Parent2"
weight = 3
It is becouse .Site.Menu.tutorial.Parent1.Weight = .Site.Menu.tutorial.Parent2.Weight = 0
Could anyone tell me how to set weight of parent menu?