Today I had to re-do (due to hugo updates, mine is now at v0.138) my old rss.xml
template modifications to ensure that RSS subscribers to my blog get access to the full contents, in addition to the post summary.
Here’s how you can do the same.
Download the original rss.xml
into the layouts/_default
directory of your blog.
Modify the <rss version ...
line to look like this:
This adds the content namespace extension so that we can use <content:encoded>
tags to add the full post content in addition to the summary.
Right below the <description>
line, add the aforementioned <content:encoded>
:
Most of this is thanks to this blog post by Nora Codes.
However, my solution adds the <![CDATA[ ... ]]
wrapper which indicates that the contained data should not be interpreted as XML, i.e. it should be passed through to the client.
You’ll note that the <description>
line in the v0.138 template applies transform.XMLEscape
instead of CDATA
. I’ve just learned that escaping and CDATA might be equivalent, although with CDATA
I don’t have to trust Hugo’s XML escaper.