Question: now in shortcodes?


I’m currently building another site with hugo and wanted to include some events from a data file in a shortcode (because I’m using markdown I cannot use this directly, correct?) And wanting to filter based on now.

I found this post: Trying to filter data files based upon a date field

And thought this should work:

{{ range where "date" "ge" .Now }}

But it does not. I get the following error:

<.Now>: can't evaluate field Now in type *hugolib.ShortcodeWithPage

The date in the events data yams has the format:
date: 2019-05-15

What am I doing wrong?
Thanks fo your help.

Instead of




thanks for the suggestion. but when I use now nothing is displayed.

You need to format the current date returned from now to match the format of your data file dates. So try:

(now.Format "2006-01-02")

Also see

thanks. more effort than I anticipated but it works :slight_smile: