Hugo escaping + char

I think this is something to do with my local setup but I can’t get hugo to stop escaping the + char in HTML.

Even a minimal example taken from Hugo’s website theme:

Results in it being escaped:

<link rel="alternate" type="application/rss&#43;xml" href="http://example.org/index.xml">

Exact same when printing just {{ .Lastmod }} for example, + is escaped.

<meta property=article:modified_time content="{{ .Lastmod }}">

Results in (bad time due to page not having a modified time):

<meta property=article:modified_time content="0001-01-01 00:00:00 &#43;0000 UTC">

Any way to prevent + being escaped? I’ve tried multiple different varieties of safeHTML, htmlUnescape etc but can’t get it to print normally.


Steps to replicate:

  1. Setup minimal hugo website (eg hugo new site .)
  2. Add below snippet or anything that prints the + char
    {{ range .AlternativeOutputFormats -}}
    <link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
    {{ end -}}
    
  3. Build website and see that char is escaped

Hugo version: Hugo Static Site Generator v0.71.0/extended darwin/amd64 BuildDate: unknown (installed via homebrew)
Env: OSX Catalina 10.15.4

This is the example from Hugo internal opengraph template:

Perfect, thats fixed it. Thanks @pamubay!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.