title: Using headless pages in section lists in hugo
body: <p>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.</p>
  
  <p>I thought that a good way to do this might be to use <a href="https://gohugo.io/content-management/page-bundles/#headless-bundle" rel="nofollow noreferrer">headless pages</a>.</p>
  
  <p>It looks like to do that, these fragments must have a directory with an <code>index.md</code>, and should be accessible using the <code>.Site.GetPage</code> operator.</p>
  
  <p>I'm struggling with figuring out how to use <code>.Site.GetPage</code> 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.</p>
  
  <p>I'm assuming either there's some magic to query multiple pages using <code>.Site.GetPage</code>, or there's an entirely different operator for this.</p>
  
  <p>That, or I've completely misunderstood how to use headless pages.</p>
  
  <p>Here's my template for the section (<code>../layouts/the-range/section.html</code>):</p>
  
  <pre><code>{{ define "main" }}
      &lt;div id="page-wrapper"&gt;
          &lt;div class="halfhero" id="map"&gt;&lt;/div&gt;
      &lt;/div&gt;
  
      {{ $sections := .Site.GetPage "/the-range/*" }}
      &lt;!-- leaf content at .../content/the-range/*/*.md --&gt;
      {{ range $sections }}
      &lt;section class="range-section"&gt;
          &lt;div class="section-content"&gt;
              {{.Content}}
          &lt;/div&gt;
          &lt;img src="{{.Site.BaseURL}}{{.Params.images}}"&gt;
      &lt;/section&gt;
  
      {{ end }}
  {{ end }} 
  </code></pre>
  
  <p>The headless content is just a series of markdown files as leaf bundles.</p>