I'm trying to list pages from a section on the front pages. This shouldn't be too hard; for example, with the following hierarchy (names genericised):
/content/
|_ test-page.md
|_ /section-name/
|_ page1.md
|_ page2.md
Using the following loop:
{{ range .Pages }}
...
{{ end }}
Gives the list page for /section-name/
as "section-names"
.
OK, well, I looked online for other solutions. For example:
{{ range first 5 (where .Data.Pages "Section" "in" (slice "section-name")) }}
But this still returns "section-names"
.
OK, so the documentation has example of where clauses and grouping. For example, {{ range (.Pages.GroupBy "Section").Reverse }}
. Let's try a similar concept:
{{ range (.Pages.GroupBy "Section") }}
{{ .Key }}
{{ range .Pages }}
{{ .Title }}
{{ end }}
{{ end }}
This seems like it would print every key, then print every page under that key. However, it prints section-name Section-names
instead of what I was hoping for, section-name page1 page2
.
What?
Also, using a simple loop like {{ range .Pages }}
, why does test
not appear as soon as a section folder is created? I don't understand Hugo's seeming obstination to show me just the section page.