I’d like to assign weights to sections so that I can manually reorder them. Is this currently possible?
If not, anyone already developed a workaround?
I’d like to assign weights to sections so that I can manually reorder them. Is this currently possible?
If not, anyone already developed a workaround?
You want to reorder this?
{{ range .Data.Pages.GroupBy "Section" }}
I’m creating an index that is ordered by section.
{{ range $section, $taxonomy := .Site.Sections }}
<h4>{{ replace $section "-" " " }}</h4>
<ul>
{{ range $taxonomy.Pages }}
<li><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
Right now it’s ordering the sections alphabetically. I’d like to manually assign weights the same way I do to content within each section.
+1.
A workaround is to use menus because their weights can be specified in config.toml
. But it requires redundant information, parent-child relationships, to be specified in each front matter of articles. For example, content/section2/article2a.md
needs
[menu.main]
parent = "section2"
So, it would be helpful if there were AllPagesMenu
option that adds all the pages to the menu.main
reflecting the directory structure. Enabling children = "section2/*.md"
in config.toml
might be fine too.
Of course introducing section weights is more reasonable.
There is an SectionPagesMenu option, see Menus | Hugo
You can set the weight for the section items in the site config — but: The pages themselves aren’t added to the menu; that was probably a design mistake …
Thank you for the quick reply. You are right. The purpose here is to list all the pages in a hierarchical manner, which is not achieved by SectionPagesMenu
.
I can live with redundant front matters (and a short script to keep their consistency) until section weights are supported.