{{/* Build slice of future events. */}}
{{ $p := slice }}
{{ range where site.RegularPages "Section" "events" }}
{{ if (.Params.event_date | time.AsTime).After now }}
{{ $p = $p | append . }}
{{ end }}
{{ end }}
{{/* Sort and show the first 5. */}}
{{ range sort $p "Params.event_date" | first 5 }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
And that’s why I prefer TOML front matter.
With TOML, date values are first-class citizens. TOML has a date data type while JSON and YAML do not. When you add a custom date field to your TOML front matter, the value is already of type time.Time and does not require conversion.