From 31dc89ef093602955a7a10f762b4f9c1423862fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Mon, 1 Jun 2026 12:58:02 +0200 Subject: [PATCH] feat(blog): add RSS 2.0 feed with autodiscovery - Add custom RSS template with Atom, content and Dublin Core namespaces - Include full post content via CDATA section - Add channel image, managingEditor, copyright and dc:creator fields - Add autodiscovery in for blog and homepage - Add visible RSS icon and link on the blog listing page --- layouts/_default/rss.xml | 52 ++++++++++++++++++++++++++++++++++++++ layouts/blog/list.html | 10 ++++++++ layouts/partials/head.html | 11 ++++++++ 3 files changed, 73 insertions(+) create mode 100644 layouts/_default/rss.xml diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml new file mode 100644 index 0000000..8fdc5c4 --- /dev/null +++ b/layouts/_default/rss.xml @@ -0,0 +1,52 @@ +{{- $pctx := . -}} +{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}} +{{- $pages := slice -}} +{{- if or $.IsHome $.IsSection -}} +{{- $pages = $pctx.RegularPages -}} +{{- else -}} +{{- $pages = $pctx.Pages -}} +{{- 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 }}{{ . }} — {{ end }}{{ .Site.Title }}{{ end }} + {{ .Permalink }} + {{ if ne .Title .Site.Title }}{{ with .Title }}{{ . }} — {{ end }}{{ end }}{{ .Site.Params.description }} + Hugo + en-ie + {{ .Site.Params.organizerName }} + {{ .Site.Params.email }} ({{ .Site.Params.organizerName }}) + {{ .Site.Params.email }} ({{ .Site.Params.organizerName }}) + {{- with .OutputFormats.Get "RSS" }} + + {{- end }} + {{- if not .Date.IsZero }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- end }} + {{- with .Site.Params.ogImage }} + + {{ . | absURL }} + {{ $.Site.Title }} + {{ $.Site.BaseURL }} + + {{- end }} + {{- range $pages }} + + {{ .Title }} + {{ .Permalink }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ $.Site.Params.organizerName }} + {{ with .Description }}{{ . | html }}{{ end }} + {{ printf "" .Content | safeHTML }} + + {{- end }} + + diff --git a/layouts/blog/list.html b/layouts/blog/list.html index cbff482..1f659c4 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -5,6 +5,16 @@

{{ .Title }}

{{ .Description }}

+ {{- with .OutputFormats.Get "RSS" }} + + {{- end }}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index dcd4613..97f8029 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -56,5 +56,16 @@ +{{/* RSS autodiscovery */}} +{{- if eq .Section "blog" }} + {{- with .OutputFormats.Get "RSS" }} + + {{- end }} +{{- else if .IsHome }} + {{- with .OutputFormats.Get "RSS" }} + + {{- end }} +{{- end }} + {{/* Structured Data / Schema.org */}} {{ partial "structured-data.html" . }}