Breaking change from 0.79.0 to 0.83.1 in Unix

I just upgraded to the newest Hugo version and I noticed that the following construct no longer works:

{{range where $pages "Params.valid_through.Unix" "gt" now.Unix}}

Params.valid_through is a param in front matter that looks like this:

valid_through = 2020-11-17T23:32:12+06:00

Suggestions? Thank you.

Update 1:

If I change the construct to use an if statement instead of the where statement it works, like so:

{{range $pages}} 
  {{if gt .Params.valid_through.Unix now.Unix}}
      ...
  {{end}}
{{end}}

Update 2:

It seems if I remove Unix from the where statement construct it works:

{{range where $pages "Params.valid_through" "gt" now}}

@runhide

I apologize. I believe I am responsible for your use of this construct:

{{ range where .Pages "Params.valid_through.Unix" "gt" now.Unix }}

In June of 2020 I recommended this while discussing “How do I use where with now function.” Although this worked with v0.72.0 (the current version at that time) through v0.82.1, I don’t understand why I didn’t just recommend:

{{ range where .Pages "Params.valid_through" "gt" now }}

This construct worked with v0.72.0 also.

Many years ago it didn’t work, but that was fixed in 2015 with:
https://github.com/gohugoio/hugo/pull/1169.

With v0.83.0 and later you cannot use my original recommendation due to this fix:
https://github.com/gohugoio/hugo/pull/8450.

Yes, we broke something that used to work, but (a) I am not convinced the broken construct is widely used, and (b) I believe the fix introduced in v0.83.0 solves a common, confusing, and time-consuming problem.

5 Likes

No problem at all. No need to apologize.

As always, appreciate your detailed responses on here and help.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.