There are a few places in my HTML that I want to format dates using the ISO 8601 full Zulu format. It’s handy to store that format in my site’s config.toml
file as a parameter. That way, if I ever need to update it, I only have to change one location.
In the config.toml
file, I add the value as a parameter:
[Params.fmt]
ISO8601 = "2006-01-02T15:04:05-07:00"
That allows me to reference it in my templates:
{{ if not .PublishDate.IsZero }}
<meta itemprop="datePublished" content="{{ .PublishDate.Format $.Site.Params.fmt.ISO8601 }}" />
{{ end }}