I can’t seem to find a solution to this problem, so I’m posting here in hopes of some help.
I have a custom string param in my front matter (I’m using YAML):
---
startdate: "2018-01-01"
---
In my single template I’m trying to convert this string into a date and customize the format. For simplicity I’ll just try to use the .Year here.
{{ $t := .Params.startdate | time }}
{{ $t.Year }}
This returns an error:
... at <$t.Year>: can't evaluate field Year in type *errors.errorString
I’m using Hugo 0.79.1 on Linux.
If I try to check the type of the output I get a time.Time object
{{ printf "%T" (.Params.startdate | time) }}
Using the time object returned by the page .Date works as expected. And the objects appear to be the same.
{{ printf "%T" .Date}} returns a time.Time object.
Any help or ideas would be greatly appreciated!