From dc54cc77c2da092996a66e0dd22ef3b74acec289 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Mon, 22 Mar 2021 19:49:48 +0530 Subject: [PATCH 1/4] Copy hugo's internal rss template - loc: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml - at commit 5f42590144579c318a444ea2ce46d5c3fbbbfe6e --- layouts/_default/rss.xml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 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 0000000000..7acdbef6be --- /dev/null +++ b/layouts/_default/rss.xml @@ -0,0 +1,39 @@ +{{- $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 }}{{.}} 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" -}} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- 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}} + {{ .Permalink }} + {{ .Summary | html }} + + {{ end }} + + From b30543b47ec91e00c836a7010c6d5bb4461052cd Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Mon, 22 Mar 2021 20:05:15 +0530 Subject: [PATCH 2/4] Add Site image from images param --- layouts/_default/rss.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 7acdbef6be..5fd8a9cd8b 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -16,6 +16,12 @@ {{ 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 }} + {{- with $.Site.Params.images }} + + {{ index . 0 | absURL }} + {{ index . 0 | absURL }} + + {{- end }} Hugo -- gohugo.io{{ with .Site.LanguageCode }} {{.}}{{end}}{{ with .Site.Author.email }} {{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}}{{ with .Site.Author.email }} From fa86dfde2dd1fb4cf2f9b9e952f6f2abb63c2270 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Tue, 23 Mar 2021 16:02:54 +0530 Subject: [PATCH 3/4] Hide search and archives layouts from feed index --- layouts/_default/rss.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 5fd8a9cd8b..1d9bce0597 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -32,6 +32,7 @@ {{ printf "" .Permalink .MediaType | safeHTML }} {{- end -}} {{ range $pages }} + {{- if and (ne .Layout `search`) (ne .Layout `archives`) }} {{ .Title }} {{ .Permalink }} @@ -40,6 +41,7 @@ {{ .Permalink }} {{ .Summary | html }} + {{- end }} {{ end }} From fd9e5604df63b0a16473dfc999b949fae8a1e6de Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Thu, 25 Mar 2021 14:14:01 +0530 Subject: [PATCH 4/4] add Description and Summary in RSS as in other templates --- layouts/_default/rss.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 1d9bce0597..64d50d79ec 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -39,7 +39,7 @@ {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} {{ .Permalink }} - {{ .Summary | html }} + {{ with .Description | html }}{{ . }}{{ else }}{{ .Summary | html }}{{ end -}} {{- end }} {{ end }}