Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Format Function converts '+' to &#43; even when contained inside a <time></time> tag #7488

Closed
Bas-Man opened this issue Jul 17, 2020 · 3 comments
Labels

Comments

@Bas-Man
Copy link

Bas-Man commented Jul 17, 2020

What version of Hugo are you using (hugo version)?

Hugo Static Site Generator v0.74.1/extended darwin/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Yes. This is the latest version and I only initially noticed it after updating as I am trying to workout a different issue.

I suspect this is a bug as it would seem that:

&#43;

would not conform to the specification for the tag as noted at https://www.w3schools.com/tags/att_time_datetime.asp

Seems there might be a need for the .Format function to be able to preserve the '+' character in some cases.

Example of code from a the Ananke theme I am currently using

      {{/* Hugo uses Go's date formatting is set by example. Here are two formats */}}
      <time class="f6 mv4 dib tracked" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}">
        {{- .Date.Format "January 2, 2006" -}}
      </time>

Produces

     <time class="f6 mv4 dib tracked" datetime="2020-07-16T00:00:00&#43;09:00">July 16, 2020</time>
@Bas-Man
Copy link
Author

Bas-Man commented Jul 17, 2020

This issue may actually trace back to the actual .Date and .Lastmod function.
I have found that the same issue occurs even without the .Format function.

@bep
Copy link
Member

bep commented Jul 17, 2020

Thanks for getting in touch, but it feels like this is a question that would be better suited to the Hugo Discussion Forum. We prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug. You may also find the answers you search for in Hugo Documentation.

@bep bep closed this as completed Jul 17, 2020
regisphilibert pushed a commit to theNewDynamic/gohugo-theme-ananke that referenced this issue Jul 20, 2020
The existing template code results in the + chartering being written in a form that is not valid for the datetime element when used in and <time> tag.

This patch fixes this issue.
references:
https://discourse.gohugo.io/t/date-lastmod-return-43-in-place-of/27033
gohugoio/hugo#7488
TiTi added a commit to TiTi/hurock that referenced this issue Sep 19, 2021
- invalid year when using 2020 as a template, see gohugoio/hugo#8983
- timezone shouldn't use &#43 but +
see gohugoio/hugo#7488
TiTi added a commit to TiTi/titi.github.io that referenced this issue Sep 19, 2021
- invalid year when using 2020 as a template, see gohugoio/hugo#8983
- timezone shouldn't use &#43 but +
see gohugoio/hugo#7488
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants