Special Content Pages

Yes, this is doable with Hugo a bunch of different ways.

You can see how I do a few versions of this at

All of which do this.

My favorite way to do this is to make a custom layout like:

layouts/thepagename/list.html

Then I put my template there, filtering to the right category or term and organizing it how I want.

Then I make a page that’s empty in:

content/myurlforpage.md

That only has the front matter:

---
title: pagename
type: thepagename
---

That will then make a page at /thepagename.

For example, this makes /letters:

{{define "main" }}
<div class="content list h-feed">
{{$pages := where .Site.Pages "Type" "post" }}
{{$letters := where $pages "Params.categories" "intersect" (slice "letters") }}
  {{ range ($letters.GroupByDate "2006-01").Reverse }}
    {{ $themonth := (time (printf "%s-%s" .Key "01")) }}
    <h1> 
      {{ if lt $themonth.Year "2023" }}
        About Letters
      {{ else }}
        {{ $themonth.Format "2006 - January" }}
      {{ end }}
    </h1>
    {{ range .Pages.Reverse }}
      {{ partial "li.html" . }}
    {{ end }}
    <hr>
 {{ end }}
</div>
{{ end }}

And this is /books:

{{ define "main" }}

{{ $books := $.Site.Data.bookshelves.currentlyreading }}
<div class="singlearea">
 <h1 class="bookshelf-name">Currently Reading</h1>
</div>
<div class="bookshelf">
    {{- range $books }}
      <a href="https://bookshop.org/a/{{ $.Site.Params.bookshop_affiliate_id }}/{{ .isbn }}">
<figure>
   <img 
      class="bookshelf-book-cover"
      src="{{ .cover_url }}"
      alt="{{ .title }} by {{ .author }}"/>
    <figcaption> {{ .title }} by {{ .author }}</figcaption>
</figure>
      </a>
    {{ end }}
</div>

{{- range $shelf, $bookshelf :=  $.Site.Data.bookshelves  }}

{{ if ne $shelf "currentlyreading" }}
<div class="singlearea">
  <h1 class="bookshelf-name">Read in {{ $shelf | replaceRE ".*(20[0-9]{2})$" "$1" }}</h1>
</div>
<div class="bookshelf">
    {{- range $bookshelf }}
  <a href="https://bookshop.org/a/{{ $.Site.Params.bookshop_affiliate_id }}/{{ .isbn }}">
<figure>
  <img 
      class="bookshelf-book-cover"
      src="{{ .cover_url }}"
      alt="{{ .title }} by {{ .author }}"/>
    <figcaption> {{ .title }} by {{ .author }}</figcaption>
</figure></a>
{{ end }}
</div>
{{ end }}
{{ end }}
{{ end }}
2 Likes