Trying to list sections and pages based on content and page params

I am trying to create a ul list of the sections of my hugo site and their child pages that have a specific param.

I basically want a multi-level ul menu at the side like so:

  • Intro
    • Page 1
    • Page 2
  • Section
    • page 3
    • page 4

Here is the Hugo Code I have so far:

<ul class="section-one-and-two-pages">
{{ range .Site.Pages }}
    {{ range where ( where .Section  "intro" ) or ".Params.type" "==" "article" }}
   <li>{{.Permalink}}{{.Title}}</li>
    {{end}}
{{ end }}
</ul>

At the top of my pages (.md) I am adding:

type: = "article"

However I cannot seem to get this to work. I keep getting the Error:

Error calling where: can’t evaluate the array by no match argument or more than or equal to two arguments

When compiling. Any ideas?

perhaps this will work for you:


{{$a := where .Site.Pages ".Section" "intro"}}
{{$b := where .Site.Pages ".Params.type" "article"}}
{{$c := $a | union $b }}
  {{ range $c }}
    <li>{{.Permalink}}{{.Title}}</li>
  {{ end }}
1 Like

I just spent days on something similar. I will do a write up on it tomorrow as I am a bit tired to post it right.