[SOLVED] All page orders are broken starting with v0.32

I’m the lead website maintainer for the Haiku project (https://www.haiku-os.org) and we use Hugo to generate the “www” site (source: github/haiku/website). We generally upgrade Hugo versions once every few months; right now we are using v0.30.2.

Upon installing v0.37 and rendering the main page, I saw that all of our content order had changed. See the homepage for how it looks right now.

And here it is on v0.32 through the current v0.37:

If you look at the dates on the posts … what’s going on here?! There are no warnings, errors, or anything else in Hugo’s command line output. The range command which is generating this output (link to it in the source) looks like this:

{{ range first 10 (where .Data.Pages "Type" "!=" "article") }}
	{{ .Render "summary" }}
{{ end }}

Various combinations of .ByDate etc. either do nothing, or cause the article list to vanish altogether. The sidebars, as you can see, have a similar problem.

I’ve read over the release notes and can find nothing that would possibly cause this; and it seems like a large enough issue that if you intentionally broke some behavior, it deserves to be documented in some prominent location…

Additionally, I had to edit this post a bunch to get by your “new users can’t post images/links” barrier. It let me upload a screenshot of what the current homepage looks like (![image|690x432](upload://z5DVm1cdTQbtJffWWRLvIbQ7fgW.png)) but then wouldn’t let me post. Um … doesn’t that cause more problems than it solves?

index.md is a reserved bundle content filename from Hugo 0.32. This is clearly stated in the release notes.

You need to take issues with the forum software with Discourse.

With the above you are not ordering the content by date. You are simply listing the articles and these are rendered as they are read from the disk, hence the random order.

To render by date see: https://gohugo.io/templates/lists#by-date

Don’t know how you got the content rendered by date with the range function that you posted prior to Hugo 0.32. Your issue doesn’t seem related to that release. Ordering has been around for a long time now.

Also regarding the restrictions on new users this is the default setting of the Discourse forum, we do get spam here, so it would be unwise to have all features enabled from the beginning on new users.

EDIT
Also I noticed that in your repo articles is set as a taxonomy and it’s also a section in your content folder. Yet you don’t specify taxonomies in your articles front matter. There was a fix for taxonomies in Hugo 0.33 the details are in the release notes. That may be a reason why you’re having problems.

That isn’t true. There is a default sort order:

  1. Weight
  2. Date
  3. LinkTitle
  4. File path

But I don’t think it is the sort order that confuses in the above.

Ok. I stand corrected.

Still there is something odd with taxonomies in that repo.

What I see is:

But it’s unclear what I need to do if I want an actual “index page” then, like I have (dozens of) now?

An “index page” in Hugo is by definition one of

  1. Home page
  2. Section list
  3. Taxonomy term list
  4. Taxonomy list

If you want content files in one or more of the above, you create _index.md or similar in the appropriate places.

Note that an “index page” isn’t just that it gets rendered to “/somepath/index.html” – also regular content pages (index.md, mypage.md) will get that in its default setting (UglyURLs turned off).

Yes, our use of taxonomies is weird, because we’re trying to get Hugo to do something that it isn’t supposed to (multi-level directory organization of “articles”).

@bep, I’ve tried renaming all index.html and .md to be _index, and now the pages beneath them in subdirectories appear, but the pages themselves named _index do not (I get served a page containing <pre></pre>). So that’s progress at least…

Are you aware of Nested Sections? This is what I use for multi-level directory organization in Hugo.

Also regarding your issue when you rename the index.md and the empty <pre> tag, the culprit is most likely the fact that _index.md refers to the list.html template and not the single.html template, as your index.md did before.

In your repo it seems that you don’t have this template under /layouts/_default and the list template that you already have under /layouts/article/list.html is empty.

1 Like

No, I wasn’t. I’ll have to check those out.

Aha, that was indeed it (although it seems that the page is actually being rendered as “section”… strange.) Thanks!

Alright, so the final upgrade was successful, however, there are 2 odd discrepancies I noticed:

  • Pages under the blog folder with a type of blog_index get rendered as blog anyway, e.g. this page. As you can see, there are not even templates for blog_index anymore (I deleted them) but no errors or warnings appear; the pages are just silently rendered as blog.
  • The /blog/ page gets rendered from the blog list template no matter what, either with or without an _index file, with or without the blog taxonomy in the config.toml, and with or without blog or blog.terms in the taxonomy templates. This one I don’t get at all; the conference and news taxonomies render from their respective templates just fine, so it doesn’t make any sense.

Thanks for all your help so far!

You can use {{ if eq .Type "blog_index" }} in your list template to specify the layout you need.

Regarding your second issue. The _index.md is meant for additional front matter that you may need on a list page, it doesn’t have anything to do with the layout. (EDIT: Unless you specify a type or layout in your _index.md)

As for your taxonomy question I don’t know why you run into this or why you need to have sections as taxonomies also. For what it’s worth taxonomies are defined in the front matter of each piece of content, but your content has no blog taxonomy defined just tags.

Again if you need a different layout you can use the snippet I posted above for your blog type.