Adding Full Post Content to Rss in Hugo
262 words, 2 minutes.
Years ago I used to aggregate all my interesting blogs and sites in an RSS reader. RSS seemed to fade away for a long time, and I thought it was dead. But, it seems to be making a resurgence — and this time around, with the contrast of how bad the rest of the internet is getting, it feels so delightful to use.
Hugo usefully has RSS feeds built in and I’ve long included an RSS version of this site. However, the default template only lists part of the article for reading in an RSS reader.
Whilst perusing Kev Quirk’s blog via NetNewsWire recently, I noticed he has a footer message thanking the reader for looking at the article via RSS.
I thought this was a neat idea — rather than forcing people to click away from the reader to the full site (“to what purpose?”), just let them read the whole article wherever they’re reading from.
With some inspiration from this post, I made a custom rss.xml file in my Hugo template layouts/_default
folder and changed the description bit to this:
<description>
{{ with .Content }}
{{ printf `<![CDATA[%s]]>` . | safeHTML }}
{{ end }}
{{ `<![CDATA[<hr><p>Thanks for reading this post via RSS! 👏</p>]]>` | safeHTML}}
{{ printf `<![CDATA[<a href="mailto:%s?subject=%s">Reply to this post by email</a>]]>` $authorEmail .Title | safeHTML }}
</description>
This expects $authorEmail to be set in params:
of your Hugo config (hugo.yml in my case):
params:
emails:
rss: "your@email.address"
Now when reading anything on this blog via RSS, you’ll get the full post right there in your reader.