💾 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.

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

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