diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 8ace530b..3691a704 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -67,7 +67,11 @@ disqusShortname = '' # When building for production it will be minified. # The file `custom.js` is loaded on each page (before body tag ends). dateFormat = "January 2, 2006" # default date format used on various pages - # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats + # See https://gohugo.io/functions/format/#hugo-date-and-time-templating-reference for available date formats. + rssFeedDescription = "summary" # available options: 1) summary 2) full + # summary - includes a short summary of the blog post in the RSS feed. Generated using Hugo .Summary . + # full - includes full blog post in the RSS feed. Generated using Hugo .Content . + # By default (or if nothing is specified), summary is used. [params.author] avatar = "avatar.jpg" # put the file in assets folder; also ensure that image has same height and width diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml new file mode 100644 index 00000000..e2aed73e --- /dev/null +++ b/layouts/_default/rss.xml @@ -0,0 +1,46 @@ + +{{- $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 -}} +{{- $rssFeedDescription := .Site.Params.rssFeedDescription | default "summary" -}} +{{- 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 + {{ site.Language.LanguageCode }}{{ 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 }} + {{ if eq $rssFeedDescription "summary"}} + {{ .Summary | html }} + {{ else if (eq $rssFeedDescription "full")}} + {{ .Content | html }} + {{ else }} {{ errorf "Error in RSS feed generation %q" .Path }} + {{ end }} + + {{ end }} + +