According to the docs content is automatically ordered by weight and then by date. Is this still the case when I query with a where clause? None of my content in this case is weighted, but each item contains a date
attribute in the frontmatter (ISO 8601 yyyy-mm-dd
).
// Query content with the tag “Florida” that is in the “news” section
{{ $pages := where (index .Site.Taxonomies.tags "Florida") "Page.Section" "news" }}
{{ range $pages }}
{{ .Page.Date }}
{{ end }}
// output:
2010-07-08 00:00:00 +0000 UTC
2010-07-02 00:00:00 +0000 UTC
2017-03-30 00:00:00 +0000 UTC
2015-11-13 00:00:00 +0000 UTC
2015-04-27 00:00:00 +0000 UTC
2015-04-20 00:00:00 +0000 UTC
2017-04-11 00:00:00 +0000 UTC
2016-11-28 00:00:00 +0000 UTC
2016-08-03 00:00:00 +0000 UTC
2016-06-01 00:00:00 +0000 UTC
2016-04-06 00:00:00 +0000 UTC
I’m using Hugo v0.20.2 on a Macbook Pro.
@rhewitt
Interesting. I just did a test on my machine (also macOS with 20.2) and am unable to reproduce the same results. Do you have a repo you can point me to? Also, did you check out the five content files that seem to be deviating?
2010-07-08 00:00:00 +0000 UTC
2010-07-02 00:00:00 +0000 UTC
...
2015-11-13 00:00:00 +0000 UTC
2015-04-27 00:00:00 +0000 UTC
2015-04-20 00:00:00 +0000 UTC
I have the whole project on GitHub, but it’s very large. I’ll see if I can pull the content files, layouts, shortcodes, etc. to make a smaller test project.
Nothing seems to be amiss with the content files; the dates are all ISO 8601.
The problem is occurring on this page, but not this one or this one.
@rdwatters
And… when I reduce the test case (copying content files directly) I get a different result??
Something weird is going on here.
Hmmm. I will take a look at this over the weekend to see if I can help, so keep me posted if you discover anything.
BTW, it’s so cool that the US Fish and Wildlife Service is using Hugo. Makes me proud(er) to be a part of this project!
2 Likes