From 9f3a9875caaded223901896f5302731d825cc0e77b54b45c2eab670f6e226b40 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson <> Date: Sun, 20 Sep 2026 00:00:00 +0000 Subject: Add Atom feeds for sections Sections were the one listing kind without a feed of their own, though the section templates already linked one whenever the output format was configured. Add the two feed templates, modelled on the taxonomy and term ones, and turn the format on for sections in the example site. Co-Authored-By: Claude Opus 5 --- CHANGELOG.md | 1 + README.md | 6 ++-- exampleSite/content/entry/welcome.md | 2 +- exampleSite/hugo.gemini.toml | 2 +- exampleSite/hugo.toml | 2 +- layouts/section.atom.xml | 53 ++++++++++++++++++++++++++++++++++++ layouts/section.gemini_atom.xml | 52 +++++++++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 layouts/section.atom.xml create mode 100644 layouts/section.gemini_atom.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 8330584..551d2b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Add example site with annotated configuration for website and capsule - Add section templates, which no output format previously had +- Add Atom feeds for sections, in both output formats - Add Atom feed autodiscovery links to document head - Support more than one audio version per entry diff --git a/README.md b/README.md index bd20521..4840260 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Every page kind that the site renders must list its output formats, because Hugo ```toml [outputs] home = ["HTML", "Atom"] - section = ["HTML"] + section = ["HTML", "Atom"] taxonomy = ["HTML", "Atom"] term = ["HTML", "Atom"] page = ["HTML"] @@ -73,12 +73,14 @@ And for the capsule: ```toml [outputs] home = ["Gemini", "Gemini_Atom"] - section = ["Gemini"] + section = ["Gemini", "Gemini_Atom"] taxonomy = ["Gemini", "Gemini_Atom"] term = ["Gemini", "Gemini_Atom"] page = ["Gemini"] ``` +A feed is rendered for every kind that lists `Atom` or `Gemini_Atom`: the homepage, each section, the taxonomy list and each term. Leave the format out of a kind to omit that feed. + ### Optional | Setting | Default | Purpose | diff --git a/exampleSite/content/entry/welcome.md b/exampleSite/content/entry/welcome.md index 614a490..08fa557 100644 --- a/exampleSite/content/entry/welcome.md +++ b/exampleSite/content/entry/welcome.md @@ -16,7 +16,7 @@ an entry's front matter to render links in place on both instead. ## What The Theme Gives You * An entry list on the homepage, and one per tag -* Atom feeds for the homepage, each tag and the tag list +* Atom feeds for the homepage, each section, each tag and the tag list * Publication date and reading time on every entry * Optional audio versions of entries * No JavaScript and no analytics diff --git a/exampleSite/hugo.gemini.toml b/exampleSite/hugo.gemini.toml index 64d3956..afca2d5 100644 --- a/exampleSite/hugo.gemini.toml +++ b/exampleSite/hugo.gemini.toml @@ -43,7 +43,7 @@ disableKinds = ["404", "sitemap"] # into the capsule. [outputs] home = ["Gemini", "Gemini_Atom"] - section = ["Gemini"] + section = ["Gemini", "Gemini_Atom"] taxonomy = ["Gemini", "Gemini_Atom"] term = ["Gemini", "Gemini_Atom"] page = ["Gemini"] diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index b964499..7a8dd83 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -43,7 +43,7 @@ enableEmoji = true # has no template for. [outputs] home = ["HTML", "Atom"] - section = ["HTML"] + section = ["HTML", "Atom"] taxonomy = ["HTML", "Atom"] term = ["HTML", "Atom"] page = ["HTML"] diff --git a/layouts/section.atom.xml b/layouts/section.atom.xml new file mode 100644 index 0000000..689c70d --- /dev/null +++ b/layouts/section.atom.xml @@ -0,0 +1,53 @@ +{{ "" | safeHTML }} +{{/* The XML declaration is emitted before anything else, including the + variables below, since whitespace may not precede it. */}} +{{ $authorName := "" }} +{{ with site.Params.author }} + {{ if reflect.IsMap . }} + {{ with .name }} + {{ $authorName = . }} + {{ end }} + {{ else }} + {{ $authorName = . }} + {{ end }} +{{ end }} +{{ if not $authorName }} + {{ errorf "Missing author" }} +{{ end }} + +{{ $authorEmail := "" }} +{{ with site.Params.author }} + {{ if reflect.IsMap . }} + {{ with .email }} + {{ $authorEmail = . }} + {{ end }} + {{ end }} +{{ end }} + +{{ $pages := .Pages.ByPublishDate.Reverse }} +{{ $limit := .Site.Config.Services.RSS.Limit }} +{{ if ge $limit 1 }} +{{ $pages = first $limit $pages }} +{{ end }} + + {{ .Permalink }} + {{ .Site.Title }} + {{ .PublishDate.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + + {{ $authorName }} + {{ with $authorEmail }} + {{ . }}{{ end }} + + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range $pages }} + + {{ .Permalink }} + {{ .Title }} + {{ .PublishDate.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ .Content | html }} + {{ end }} + diff --git a/layouts/section.gemini_atom.xml b/layouts/section.gemini_atom.xml new file mode 100644 index 0000000..6425e31 --- /dev/null +++ b/layouts/section.gemini_atom.xml @@ -0,0 +1,52 @@ +{{ "" | safeHTML }} +{{/* The XML declaration is emitted before anything else, including the + variables below, since whitespace may not precede it. */}} +{{ $authorName := "" }} +{{ with site.Params.author }} + {{ if reflect.IsMap . }} + {{ with .name }} + {{ $authorName = . }} + {{ end }} + {{ else }} + {{ $authorName = . }} + {{ end }} +{{ end }} +{{ if not $authorName }} + {{ errorf "Missing author" }} +{{ end }} + +{{ $authorEmail := "" }} +{{ with site.Params.author }} + {{ if reflect.IsMap . }} + {{ with .email }} + {{ $authorEmail = . }} + {{ end }} + {{ end }} +{{ end }} + +{{ $pages := .Pages.ByPublishDate.Reverse }} +{{ $limit := .Site.Config.Services.RSS.Limit }} +{{ if ge $limit 1 }} +{{ $pages = first $limit $pages }} +{{ end }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Site.Title }} + {{ .PublishDate.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + + + {{ $authorName }} + {{ with $authorEmail }} + {{ . }}{{ end }} + + Hugo -- gohugo.io + {{ replace .Site.Copyright "{currentYear}" (now.Format "2006") }} + {{ .Site.Params.Description }}{{ range $pages }} + + {{ .Permalink | strings.TrimSuffix "index.gmi" }} + {{ .Title }} + {{ .PublishDate.Format "2006-01-02T15:04:05-0700" | safeHTML }} + + {{ end }} + -- cgit v1.2.3