I have nested content sections with leaf and branch bundles. Is there a single function to get all _index.md
in a recursive manner?
See https://gohugo.io/variables/page/#page-variables
.BundleType
the bundle type:
leaf
,branch
, or an empty string if the page is not a bundle.
1 Like
Great, thank you. Are these approaches identical? Are there any undocumented best practices or Hugoisms to consider?
{{ $pages := where $.Site.Pages "Section" "my_section"}}
{{ range where $pages "BundleType" "branch"}}
{{ .}}
{{ end }}
{{ $pages := where (where $.Site.Pages "Section" "my_section") "BundleType" "branch"}}
{{ range $pages }}
{{ . }}
{{ end }}
Yeah, they’re the same. To avoid initializing a var you can:
{{ range where (where $.Site.Pages "Section" "my_section") "BundleType" "branch" }}
{{ . }}
{{ end }}
But I think readability trumps efficiency; your choice.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.