How do I output the {{ .Content }} as HTML with character entities decoded?

We are trying to get our RSS feeds in HUGO working and the problem we are running into is that all of our posts .md files (we have a few thousand) have special chars in them like ’

And XML does not support character entities. So they need to be transformed before being inserted into our feeds.

What is the best way to output the {{ .Content }} as HTML with character entities decoded?

In the RSS feed template, I am trying

this just encodes everything
<content:encoded>{{ .Content | html }}</content:encoded>

this produces decent HTML but the entities are not transformed.
<content:encoded>{{ .Content | safeHTML }}</content:encoded>

not sure if I should be using CDATA ot not…
<content:encoded>{{chomp "<![CDATA[\n"}}{{ .Content | safeHTML }}{{chomp "]]>\n"}}</content:encoded>

So it looks like the correct function is:
<content:encoded>{{ htmlUnescape .Content | safeHTML }}</content:encoded>

However, I noticed that when we do pull in the full content, it also pulls in the shortcodes which will also need to be filtered or removed (sigh)

1 Like

The built in RSS template uses <description>{{ .Summary | html }}</description> if that’s helpful.

1 Like

Try this.
content:encoded{{ <![CDATA[ | safeHTML }}{{ .Content | safeHTML }}{{ ]]> | safeHTML }}</content:encoded>