Filter where customdate ge .Now

Hi,

I am setting my first steps in Hugoland, and I am looking on how to filter pages by only showing them if ‘startdate’, a custom date from the front matter, is greater then now.

I managed to filter by type, and sort by this custom date field, but i cant seem to find a way to filter future dates.

This is what I have:

{{ $paginator := .Paginate (where .Pages "Type" "event") }}
    {{ range ($paginator.Pages.ByParam "startdate") }}
        {{ .Title }}
    {{ end }}

Any help would be appreciated.

Cheers!
Tom Behets

Untested, but try something like this within the range:

{{ if gt .Params.startdate (now.Format “2006-01-02”) }}
  {{ .Title }}
{{ end }}

This assumes that your startdate front matter variable is formatted like YYYY-MM-DD

1 Like

that works perfectly!
Thanks zwbetz,

Cheers,
betz :wink:

1 Like

A post was split to a new topic: Paginate future-dated pages