Hugo Static Site Generator v0.55.0/extended darwin/amd64 BuildDate: unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.12.2"
Only built a few simple sites with Hugo and want to build a multilingual one. This is an event website so dates are pretty important. It’s also a multilingual setup with content in sub folders.
I only managed to format custom dates with dateFormat
but the docs say it is not supported with multilingual setups …
I have the following custom dates in front-matter
---
date: "2019-03-03T14:00:00"
startDate: "2019-03-03T14:00:00"
endDate: "2019-03-03T18:00:00"
title: "this is a title in english"
slug: "this-test-event-english"
---
If I try to use .Format
it does not work
{{ range where (.Pages.ByParam "startDate").Reverse "Type" "programme" }}
<li>
<p>{{ .Params.startDate.Format "January 2, 2006" }}</p>
<h3>{{ .Title }}</h3>
</li>
{{ end }}
I have the following error
Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: index.html:7:19: executing "main" at <.Params.startdate.format>: can't evaluate field format in type interface {}
The same code but using .Date
works
{{ range where (.Pages.ByParam "startDate").Reverse "Type" "programme" }}
<li>
<p>{{ .Date.Format "January 2, 2006" }}</p>
<h3>{{ .Title }}</h3>
</li>
{{ end }}
I can format my custom dates using dateFormat
like so but the doc says it is not supported for multilingual setups anymore. The lack of multilingual support for dates in Go is also quite problematic and would force me to use .Format
it seems.
{{ range where (.Pages.ByParam "startDate").Reverse "Type" "programme" }}
<li>
<p>{{ dateFormat "January 2, 2006" .Params.startDate }}</p>
<h3>{{ .Title }}</h3>
</li>
{{ end }}
What am I supposed to do ?
This is really a bummer because, apart from that date parsing / localisation problem, the rest of the localisation functionalities in Hugo are pretty great …