Updated Hugo adds record in range


I updated Hugo and am now getting some strange behavior. Sadly, I don’t remember what version I was on previously, but I’m currently on v0.41.

This is the code that is behaving oddly:

    {{ range (where .Site.Pages "Section" "employment").ByDate.Reverse  }}
        {{ .Render "single" }}
    {{ end }}

Previously, it would render one “single” for each file. Now it is rendering for each file, plus and extra record. When I sort with “.Reverse” the empty record is on type. Without it, the empty record is on the bottom.

Also, it seems to be an extra “empty” record, it’s not entirely empty. The Title field is populating with “Employments.”

It seems like something built in, but I can decipher what.



For future, always note the last version that worked for you, and then update. Arbitrarily updating versions is not a good idea.

What’s an extra record.

If earlier you were on a version older than Hugo 0.32, you would need to read up on Page Bundles. It’s possible that you are using index.md where it should be _index.md instead.

If above is not the problem, you will need to share a repo with minimal set of files that reproduces the issue you see.


Okay, I have some more information. I rolled back hugo to version 0.29 and restarted the dev server. My website is back to functioning as normal. So, somewhere between 0.29 and 0.41 there was a functionality change that affects how many instances are found in this code:

{{ range (where .Site.Pages "Section" "employment").ByDate.Reverse  }}
  {{ .Render "single" }}
{{ end }}

I used the word “record” before, and it may have been more accurate to say “entry.” In my content folder, have an employment folder. In that folder, have 3 markdown files (i.e. 3 entries). I would expect this statement (from above):

  {{ .Render "single" }}

To render 3 and only 3 entries using the template single. In fact, it renders 4 entries. One of the entries populates the Title column with data that does not appear in the content/employment folder (in fact, I can’t find any place with that content).

Does that help state the problem more clearly? Any ideas?



See https://gohugo.io/variables/site/#site-variables-list

You’re right, there were some changes and there is a difference between .Site.Pages and .Site.RegularPages.


That was the ticket!

Replacing .Site.Pages with .Site.RegularPages did the trick. thanks!