How do i add the _index.md page of a branch bundle to the list of posts?

The theme that i am using for my site uses the following code to list posts:

{{- $pages := union .RegularPages .Sections }}

But this list is missing, the _index.md pages.

For example, if the content is structured like so:

content
|-- posts
|   |-- a
|   |   |-- _index.md
|   |   `-- b.md

Only, b.md appears in the list. But, i want both _index.md, b.md.

1 Like

See https://gohugo.io/variables/page/#pages

Thanks for the reply. Am afraid, the reference did not turn out to be of much help.

Tried to switch from .RegularPages to .Pages (and also tried .RegularPagesRecursive)

But the results are the same.

Combine the two:

{{ range union .Pages .RegularPagesRecursive }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

Thank you, it works !

Refining it a little bit by sorting the combined list before rendering:

{{- $pages := (union .Pages .RegularPagesRecursive).ByDate.Reverse }}

So, it seems .Pages misses the sub pages, while .RegularPagesRecursive misses the branch bundles. Combined they do the job.

Turns out, the theme also had some additional filtering going on for the home page and that did cause additional confusion when i tried yesterday.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.