Iβve got a requirement to build a section page that is comprised of some static header material, static footer material, and several sections of user-managed content. This user managed content is fragmentary, and as such should not have a permalink.
I thought that a good way to do this might be to use headless pages. If this is the wrong approach, stop here and tell me so.
It looks like to do that, these fragments must have a directory with an index.md
, and should be accessible using the .Site.GetPage
operator.
Iβm struggling with figuring out how to use .Site.GetPage
to get a list of pages to iterate over. There will be 2β¦n user sections, and I donβt want to rebuild the sectionβs template if the number of content modules changes.
Iβm assuming either thereβs some magic to query multiple pages using .Site.GetPage
, or thereβs an entirely different operator for this.
That, or Iβve completely misunderstood how to use headless pages.
Hereβs my template for the section ( ../layouts/the-range/section.html
):
{{ define "main" }}
<div id="page-wrapper">
<div class="halfhero" id="map"></div>
</div>
{{ $sections := .Site.GetPage "/the-range/*" }}
<!-- headless leaf content at .../content/the-range/*/index.md -->
{{ range $sections }}
<section class="range-section">
<div class="section-content">
{{.Content}}
</div>
<img src="{{.Site.BaseURL}}{{.Params.images}}">
</section>
{{ end }}
{{ end }}
The headless content is just a series of markdown files as leaf bundles.