List all sibling pages in a section including _index

A site has many sections and I’d like to have a partial that outputs a list of all sibling pages within that current section. Each section has an but this page isn’t a listing page its just another sibling page. Is there any way to grab a list that includes the _index,md page? I’ve been using .CurrentSection.Pages which is great it returns all the pages but no _index page.

I can manually prepend it to my list as removing the _index means the section isn’t a real section and .CurrentSection.Pages stops working as I’d like. I can’t really have as a blank page as its needed to ensure it acts like a section so its a dilemma.

My interpretation of the documentation is that this isn’t possible but any ideas would be appreciated, thanks.

Example section


Did you tried .Data.Pages ? It’s render the page also.

Thanks but .Data.Pages returns Pages(0) for me at my section level.

Interesting that in the scenario I have described the _index is actually the .Parent page and not a sibling page.

This is what I’m using and it is sufficient. I only include the partial if len .CurrentSection.Pages is greater than zero.

    <a href="{{ .CurrentSection.Permalink }}">{{ .CurrentSection.Title }}</a>
  {{ range .CurrentSection.Pages }}
    <a href="{{ .Permalink }}">{{ .Title }}</a>
  {{ end }}

If Pages does not return the Section, it suggests that you’re on a very old Hugo version. That was the behaviour at some point (back then people used {{ $pages := .Pages | union .Sections }}.

OK, thank you I will investigate.

I’m using using hugo v0.87.0+extended darwin/amd64 BuildDate=unknown