I’m seeing what looks like double-encoding behavior with a template and I’m trying to figure out what’s happening. My template is for RSS, and it includes the following:
<title>{{ cond (eq .Site.Params.titlecase true) (.Title | title | markdownify | html) (.Title | markdownify | html) }}</title>
<description>{{ with .Params.tldr }}{{ . | markdownify | html }}...
If I include a single-quote in the title, and set both the title and tldr in the front matter of a piece of content to the same value with the same single-quote, like this:
title: "Golang's Database/SQL in Action"
tldr: "Golang's Database/SQL in Action"
The resulting output is:
<item>
<title>Golang&amp;rsquo;s Database/SQL in Action
<description>Golang&rsquo;s Database/SQL in Action
</item>
My site’s config has titlecase: true.
Why is the title getting the entities double-encoded?
I think I’m asking my question really badly, my apologies for that. The variables should have the same content; or at least I’ve written the same thing in the front matter. The variables are going through the same | markdownify | html sequence of functions. But they have different output: one is double encoded and the other one isn’t.
Actually, to be a little more clear, one of the things that was confusing me is that previewing an RSS feed in a Chrome or Firefox browser decodes HTML entities from the description element, but not from the title, making it look like the output from Hugo was different when in fact it was the same. So, between that confusion and the differences in the template functions, which I wasn’t noticing, was my problem.