Hi! I’m very new to Hugo and i’m confused with what i’m doing. I’m trying my best to learn and to create my own documentation theme from scratch to have a fully customized theme.
I’m creating a documentation site that has at least 3 sections at the minimum. What I want is to list the section pages like this:
I want to do this dynamically so I don’t need to fiddle with the config.toml everytime a page needs to be created. My goal is to complete this documentation site to the authors so they can create the hugo content without editing anything with the config file.
This is what my sidebar partial looks like:
<div class="sidebar-section py-3">
{{ $currentPage := . }} {{ range .Site.Menus.main }}
<h4 class="{{ if $currentPage.HasMenuCurrent " main " . }}active{{ end }}">
<a href="{{ .URL }}" class="active">
<span>{{ .Name }}</span>
</a>
</h4>
{{ end }}
{{ $sectionPages := where .Site.Pages "Section" .Section }} {{ if ge (len $sectionPages) 1 }}
<ul class="sub-menu mb-5 ml-4">
{{ range $sectionPages }}
<li>
<a href="{{ .URL }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
</div>
One of my section pages looks like this:
Brand Guidelines and Digital Guidelines are menu items that I created on my config.toml page while the pages below are ranged as Section Pages. The way that my range function also lists “Brand Guidelines” drives me nuts. This is supposed to be the title of the section. I’ve already read the docs, watched youtube tutorials etc. I don’t want to give up but i’m stumped. I know that my method is incorrect and I hope that someone here would help me figure this out.
Here is my bitbucket if it helps: https://bitbucket.org/annady24/hugo-documentation-site/src/master/
Thanks!