[NOT A REAL PROBLEM] How to avoid HTML ascii code in SEO <meta> tags?

I have some variable I use for SEO tags wich contains 'character (ascii 39).

Whatever pipe (htmlUnescape, safeHTML and al.) i try, even using \u0027, the ' is always transformed to &#39;.

  • Is it me forgettting some obvious thing ?
  • Is it by design ? If so i think we should have a way to keep the SEO tag free of ascii codes because it renders the brute codes when processed by SEO tools/functions.

Any light on this ?

Hugo code

title = "Val d'Hérens"
<meta property="og:title" content="{{ .Site.Title }}" />

HTML results

<meta property="og:title" content="Val d&#39;Hérens" />

expected result

<meta property="og:title" content="Val d'Hérens" />

What happens if you print .Site.Title first?

Like so: {{ $title := print .Site.Title }}

And then
<meta property="og:title" content="{{ $title }}" />

I can reproduce.

An ASCII character like the middot is outputted in the source of an HTML pageas &middot;

But in the browser the title displays the rendered ·

Also when syndicating a page to Social Media (like Facebook) and in Google’s SERPs the middot is rendered correctly as ·

@alexandros thanks a lot for the response.
But your tip doesn’t change things.

The browser display is OK, FB seems ok but I had problem with other site/tools (but i just F&@#% can’t found wich one at the moment) who doesn’t do the translation.

Anyway thanks, seems the legit behaviour and good enough.
I guess if it works with greek alphabet it should work with roman one :slight_smile:

Again thanks a lot for the help & time.

Those tools that don’t do the translation are maintained by people who either don’t care or simply don’t know how to configure their servers properly.

I’ve encountered quite a few of those in the past, since I often work with greek content.

Yep. I’m new to SEO so the poor little thing (me) freaked I out with this.
So I mark this issue as resolved/fake news :slight_smile:

Thanks a lot for the light ! And sorry for the noise.

If you really want to know the technical stuff behind this, you could find this read interesting: https://golang.org/pkg/html/template/

Basically the template system that Hugo uses is context aware and doesn’t trust stuff that is parametrized. That’s why the safe functions exist, to tell the template explicitly “you can trust this”. However, I found that in some contexts even the result of the safe functions is filtered. I don’t think there’s a way to bypass this. However if you hardcode the attribute it is rendered as it was written (because it is trusted).