Trying to test out the new Time.Format in Hugo 87, but not able to access that from the config file.
I have put the following in both en and fr in my config and I can print the values of those settings:
languages:
fr:
dateFormat: ":date_short"
params:
dateFormat: ":date_long"
And in my layout I’ve been testing:
{{ printf "%#v" .Site.Params.dateFormat }}
{{ printf "%#v" .Site.Params.params.dateFormat }}
{{ $datestr := .Site.Params.dateFormat }}
{{ printf "%#v" $datestr }} < prints string in page
{{ $datestr := .Site.Params.params.dateFormat }}
{{ printf "%#v" $datestr }} < prints string in page
{{ $datestr := .Site.Params.params.dateFormat }} < doesn't work
{{ $datestr := ":date_long" }} < works
{{ with .Date | time.Format $datestr }}
{{ i18n "postedOnDate" . }}
{{ end }}
If I set $datestr directly to “:date_long” the {{ with }} section above runs fine and prints the date in the appropriate format for the language. But if i set $datestr to any of the .Site.paramaters (which print fine), then I get an error message:
"partials/post-meta.html" at <$datestr>: invalid value; expected string
What am I doing wrong here??? Thanks!