Last active 1725838849

I DON'T THINK THIS SATISFIES THE https://validator.w3.org/feed/docs/atom.html#sampleFeed spec Modify hugo's default RSS feed to make the post's content shown be the post's full content and not only a short snippet of it. To be placed as layouts/index.xml (or renamed to whatever the feed name would be )

Revision fbd6a07494178094baf124b82fa26416fc5c222c

aaareadme.txt Raw
1From <https://github.com/ttys3/hugo-theme-terminal/blob/86c8d80e396b82f28927b659e0e0edd9d8959afe/layouts/_default/home.rss.xml>
2
3You should probably use this instead.
4
5<EOF
6{{- $pctx := . -}}
7{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
8{{- $pages := slice -}}
9{{- if or $.IsHome $.IsSection -}}
10{{- $pages = $pctx.RegularPages -}}
11{{- else -}}
12{{- $pages = $pctx.Pages -}}
13{{- end -}}
14{{- $limit := .Site.Config.Services.RSS.Limit -}}
15{{- if ge $limit 1 -}}
16{{- $pages = $pages | first $limit -}}
17{{- end -}}
18{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
19<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
20 <channel>
21 <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
22 <link>{{ .Permalink }}</link>
23 <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
24 <generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
25 <language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
26 <managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
27 <webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
28 <copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
29 <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
30 {{ with .OutputFormats.Get "RSS" }}
31 {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
32 {{ end }}
33 {{ range $pages }}
34 <item>
35 <title>{{ .Title }}</title>
36 <link>{{ .Permalink }}</link>
37 <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
38 {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
39 <guid>{{ .Permalink }}</guid>
40 <description>{{ .Summary | html }}</description>
41 <content:encoded>
42 {{ `<![CDATA[` | safeHTML }}
43 {{ .Content }}
44 {{ `]]>` | safeHTML }}
45 </content:encoded>
46 </item>
47 {{ end }}
48 </channel>
49</rss>
50EOF
51
index.xml Raw
1{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
2{{- $authorEmail := "" }}
3{{- with site.Params.author }}
4 {{- if reflect.IsMap . }}
5 {{- with .email }}
6 {{- $authorEmail = . }}
7 {{- end }}
8 {{- end }}
9{{- else }}
10 {{- with site.Author.email }}
11 {{- $authorEmail = . }}
12 {{- warnf "The author key in site configuration is deprecated. Use params.author.email instead." }}
13 {{- end }}
14{{- end }}
15
16{{- /* Deprecate site.Author.name in favor of site.Params.author.name */}}
17{{- $authorName := "" }}
18{{- with site.Params.author }}
19 {{- if reflect.IsMap . }}
20 {{- with .name }}
21 {{- $authorName = . }}
22 {{- end }}
23 {{- else }}
24 {{- $authorName = . }}
25 {{- end }}
26{{- else }}
27 {{- with site.Author.name }}
28 {{- $authorName = . }}
29 {{- warnf "The author key in site configuration is deprecated. Use params.author.name instead." }}
30 {{- end }}
31{{- end }}
32
33{{- $pctx := . }}
34{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
35{{- $pages := slice }}
36{{- if or $.IsHome $.IsSection }}
37{{- $pages = $pctx.RegularPages }}
38{{- else }}
39{{- $pages = $pctx.Pages }}
40{{- end }}
41{{- $limit := .Site.Config.Services.RSS.Limit }}
42{{- if ge $limit 1 }}
43{{- $pages = $pages | first $limit }}
44{{- end }}
45{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
46<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
47 <channel>
48 <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
49 <link>{{ .Permalink }}</link>
50 <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
51 <generator>Hugo</generator>
52 <language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
53 <managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
54 <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
55 <copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
56 <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
57 {{- with .OutputFormats.Get "RSS" }}
58 {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
59 {{- end }}
60 {{- range $pages }}
61 <item>
62 <title>{{ .Title }}</title>
63 <link>{{ .Permalink }}</link>
64 <pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
65 {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
66 <guid>{{ .Permalink }}</guid>
67 <description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
68 </item>
69 {{- end }}
70 </channel>
71</rss>
72