I would like to list all sections in Posts. But using {{ range .Sections }}
doesn’t work for. Is the section not setup correctly?
:
Your code works if your content has this structure:
content/
├── posts/
│ ├── bar/
│ │ ├── _index.md <-- the presence of an _index.md file makes this a section
│ │ ├── bar-1.md
│ │ └── bar-2.md
│ ├── foo/
│ │ ├── _index.md <-- the presence of an _index.md file makes this a section
│ │ ├── foo-1.md
│ │ └── foo-2.md
│ └── _index.md <-- the presence of an _index.md file makes this a section
└── _index.md
Thanks a lot for your help.
Now i would like to get the Name of the Section.
{{ range .Sections }}
$sectionName := .Section }}
But this gets me ‘posts’ instead of ‘bar’.
A section is a page so use page title.