rss.xml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {{- /* Generate RSS v2 with full page content. */ -}}
  2. {{- /* Upstream Hugo bug - RSS dates can be in future: https://github.com/gohugoio/hugo/issues/3918 */ -}}
  3. {{- $page_context := cond .IsHome site . -}}
  4. {{- $pages := $page_context.RegularPages -}}
  5. {{- $limit := site.Config.Services.RSS.Limit -}}
  6. {{- if ge $limit 1 -}}
  7. {{- $pages = $pages | first $limit -}}
  8. {{- end -}}
  9. {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
  10. <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  11. <channel>
  12. <title>{{ if ne .Title site.Title }}{{ with .Title }}{{.}} | {{ end }}{{end}}{{ site.Title }}</title>
  13. <link>{{ .Permalink }}</link>
  14. {{- with .OutputFormats.Get "RSS" }}
  15. {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
  16. {{ end -}}
  17. <description>{{ .Title | default site.Title }}</description>
  18. <generator>Wowchemy (https://wowchemy.com)</generator>
  19. {{- with site.LanguageCode }}<language>{{.}}</language>{{end -}}
  20. {{- with site.Copyright }}<copyright>{{ replace (replace . "{year}" now.Year) "&copy;" "©" | plainify }}</copyright>{{end -}}
  21. {{- if not .Date.IsZero }}<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end -}}
  22. {{- if .Scratch.Get "og_image" }}
  23. <image>
  24. <url>{{ .Scratch.Get "og_image" }}</url>
  25. <title>{{ .Title | default site.Title }}</title>
  26. <link>{{ .Permalink }}</link>
  27. </image>
  28. {{end -}}
  29. {{ range $pages }}
  30. <item>
  31. <title>{{ .Title }}</title>
  32. <link>{{ .Permalink }}</link>
  33. <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
  34. <guid>{{ .Permalink }}</guid>
  35. <description>{{ .Content | html }}</description>
  36. </item>
  37. {{ end }}
  38. </channel>
  39. </rss>