[Solved] How to test if a section exists?


before nested sections were introduced I used isset to test if a second exists:

{{ if  isset .Site.Sections "article"  }}

How would I do that with nested sections?
Site.Sections which should hold the top level sections seems to return page objects. I couldn’t figure out how to test them against the section name. I also found Site.Params.mainSections in the hugo source which should hold the section name strings in something array-isch. Unfortunately it appears to hold only one section. Any ideas?

Thanks for your support.


{{ with .Site.GetPage "section" "article" }}...{{ end }}

Similar with if.

1 Like

Works, thank you bep.