💾 SuperFloppies Place! 💾

Hugo: List Pages in a Section

To list pages in a single section in Hugo, create the following as layouts/shortcodes/SECTION_NAME.html, the following is used on this site and invoked on the home/landing page to list my snips.

<ul>
    {{ range first 5 (where .Site.Pages "Type" "snip") }}
        {{ if ne .Title "Snips" }}
            <li>
                <a href="{{ .Permalink }}">{{ .Title }}</a> &mdash;
                Published {{ dateFormat "Monday, January 2, 2006" .Date }}.
            </li>
        {{ end }}
    {{ end }}
</ul>

Due to laziness, I haven’t genericized it, yet.