Please notice: This article is more than 3 years old
Content, Source code or links may no longer be correct in the meantime.
Please notice: This article is more than 3 years old
Content, Source code or links may no longer be correct in the meantime.
This weekend, Jochen T. contacted me with an interesting question about Hugo and the theme I am using for this blog:
I don’t understand how I can create a “normal” feed, I have searched for help, but found nothing. My feed only contains the categories “micro”, “blog” or “page”, but I would like to have a feed with the individual posts in full text (like you).
Due to the fact that others might have the same question, I answer this in the public of course after prior request and approval by Jochen.
Well, the easy way is to check Hugos’ config.toml first. Under [params.rss] and due to the fact I’m bilingual, under [languages.en.params.rss] aswell, please check if includeContent = true is set.
If not sufficient, here is my /themes/kiss-em-master/layouts/_default/index.rss.xml file for copying and pasting. Looking into my git-repo, I can say that only the loop in .Site.Pages.ByDate.Reverse has been altered to reverse order alongside with an additionally if-clause:
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title.Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title.Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<language>{{ .Site.Language }}</language>
<contact>{{ $.Site.Params.rss.authorEmail }}</contact>
<copyright>{{ .Site.Params.Info.Copyright | safeHTML}}</copyright>
{{ with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{ end }}
{{ range .Site.Pages.ByDate.Reverse }}
{{ if .Content }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<author>{{ $.Site.Params.rss.authorName }}</author>
<guid>{{ .Permalink }}</guid>
<description>{{ .Description | html }}</description>
{{ if $.Site.Params.rss.includeContent }}
<content>{{ .Content | html }}</content>
{{ end }}
</item>
{{ end }}
{{ end }}
</channel>
</rss>
Hope this is helpful, Jochen.
Wish you and everybody a good start into the new week,
Tomas Jakobs