Hugo: ISO8601 issue with internal template

Created on 21 Sep 2018  路  9Comments  路  Source: gohugoio/hugo

This might not be much of an issue, but when using the internal template such as OpenGraph the datetime's offset + or - is not shown. Example

date: 2018-09-20T16:37:20+12:00

is shown as

<meta property="og:updated_time" content="2018-09-20T16:37:20&#43;12:00"/>

Instead of

<meta property="og:updated_time" content="2018-09-20T16:37:20+12:00"/>

I am using Hugo v0.48/extended windows/amd64.

Most helpful comment

@akshaybabloo It's not going to until the upstream PR that I linked is merged and a new Hugo release based on that new Go version is released as well.

All 9 comments

How is this a problem?

@akshaybabloo.

FYI, the escaped HTML for + wasn't an issue when I tested it locally using Facebook's OGP's debugger. It still converted to UNIX time effectively.

Hey. This is an issue because safeHTMLAttr shouldn't escape "+"s but it is. I see two components here:

  1. The line in Hugo doing this is using safeHTML when it should probably be using safeHTMLAttr.

    • shouldn't be escaped. This isn't a Hugo issue though as I have tracked it to the html/template Go package. I'm investigating if I can do a PR upstream if I understand it well enough.

This issue clearly isn't anything major but I made an upstream PR to have Go's html/template stop escaping plus signs and then a PR for Hugo to use the right function.

This did not fix the issue. I still get

<meta property="og:updated_time" content="2018-09-20T16:37:20&#43;12:00"/>

but this on template works:

{{ print "2018-09-20T16:37:20+12:00" | safeHTML }}

@rdwatters True, but just for the sake of consistency.

@felicianotech It's not working for me still.

@akshaybabloo It's not going to until the upstream PR that I linked is merged and a new Hugo release based on that new Go version is released as well.

I've noticed that schema template is still escaping the plus and not using safeHTMLAttr:

https://github.com/gohugoio/hugo/blob/c3d433af56071d42aeb3f85854bd30db64ed70b8/tpl/tplimpl/embedded/templates/schema.html#L5-L6

Might have been missed?

Was this page helpful?
0 / 5 - 0 ratings