From 9c57c96aeeea7c34b94f0d12a8f7eb6d4f554258 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Thu, 12 Mar 2026 14:22:44 +0100 Subject: [PATCH] fix(rss): update RSS template and Hugo version for compatibility Hugo v0.156.0 removed the deprecated .Site.Author field, breaking the RSS template. Align the RSS template with Hugo's current embedded default by using site.Params.author, transform.XMLEscape, .PublishDate, and proper lastBuildDate computation. Bump CI Hugo version from 0.151.0 to 0.157.0. Signed-off-by: Marco Nenciarini --- .github/workflows/hugo_build.yml | 2 +- layouts/home.rss.xml | 74 ++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/.github/workflows/hugo_build.yml b/.github/workflows/hugo_build.yml index bb930e6e3..da81b57da 100644 --- a/.github/workflows/hugo_build.yml +++ b/.github/workflows/hugo_build.yml @@ -36,7 +36,7 @@ jobs: - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: - hugo-version: "0.151.0" + hugo-version: "0.157.0" extended: true - name: Build diff --git a/layouts/home.rss.xml b/layouts/home.rss.xml index bbc02b9df..b9d989e71 100644 --- a/layouts/home.rss.xml +++ b/layouts/home.rss.xml @@ -1,39 +1,59 @@ -{{- $pctx := . -}} -{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} -{{- $pages := slice -}} -{{- if or $.IsHome $.IsSection -}} -{{- $pages = where $pctx.RegularPages "Type" "blog" -}} -{{- else -}} -{{- $pages = where $pctx.Pages "Type" "blog" -}} -{{- end -}} -{{- $limit := .Site.Config.Services.RSS.Limit -}} -{{- if ge $limit 1 -}} -{{- $pages = $pages | first $limit -}} -{{- end -}} +{{- $authorEmail := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .email }} + {{- $authorEmail = . }} + {{- end }} + {{- end }} +{{- end }} + +{{- $authorName := "" }} +{{- with site.Params.author }} + {{- if reflect.IsMap . }} + {{- with .name }} + {{- $authorName = . }} + {{- end }} + {{- else }} + {{- $authorName = . }} + {{- end }} +{{- end }} + +{{- $pctx := . }} +{{- if .IsHome }}{{ $pctx = .Site }}{{ end }} +{{- $pages := slice }} +{{- if or $.IsHome $.IsSection }} +{{- $pages = where $pctx.RegularPages "Type" "blog" }} +{{- else }} +{{- $pages = where $pctx.Pages "Type" "blog" }} +{{- end }} +{{- $limit := .Site.Config.Services.RSS.Limit }} +{{- if ge $limit 1 }} +{{- $pages = $pages | first $limit }} +{{- end }} {{- printf "" | safeHTML }} - {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }} + {{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }} {{ .Permalink }} - Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }} - Hugo -- gohugo.io{{ with .Site.LanguageCode }} - {{.}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} - {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Copyright }} - {{.}}{{end}}{{ if not .Date.IsZero }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} - {{- with .OutputFormats.Get "RSS" -}} + Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }} + Hugo + {{ site.LanguageCode }}{{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with $authorEmail }} + {{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }}{{ with .Site.Copyright }} + {{ . }}{{ end }}{{ if not .Date.IsZero }} + {{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}{{ end }} + {{- with .OutputFormats.Get "RSS" }} {{ printf "" .Permalink .MediaType | safeHTML }} - {{- end -}} - {{ range $pages }} + {{- end }} + {{- range $pages }} {{ .Title }} {{ .Permalink }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- with $authorEmail }}{{ . }}{{ with $authorName }} ({{ . }}){{ end }}{{ end }} {{ .Permalink }} - {{ .Summary | html }} + {{ .Summary | transform.XMLEscape | safeHTML }} - {{ end -}} + {{- end }}