gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.85k stars 7.54k forks source link

Validate taxonomies configuration #12317

Open arranf opened 7 months ago

arranf commented 7 months ago

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.124.1-db083b05f16c945fec04f745f0ca8640560cf1ec+extended darwin/arm64 BuildDate=2024-03-20T11:40:10Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes.

Issue Description

Hugo fails to resolve the correct template for the homepage under the following conditions:

In my main project, setting disableKinds = ['taxonomy', 'term', 'section'] fixes the issue however I could not reproduce that in the reproduction repo (see: steps to reproduce).

Obviously an array in taxonomies is invalid configuration however I believe this is a regression. This was not an issue in 0.112.7. After upgrading to 0.121.2 I started observing this issue occasionally as a race condition, as of 0.123.8 onwards this bug is reproducible every time hugo executes.

Steps to Reproduce

See: https://github.com/arranf/hugo-homepage-template-reproduction

  1. Clone down the repo
  2. Run hugo --printUnusedTemplates --logLevel debug --cleanDestinationDir --ignoreCache
  3. Note that /layouts/index.html is unused causing issues with the site build

Possibly Related Issues

jmooring commented 7 months ago

Why are you doing this?

[taxonomies]
example = []

This is a self-inflicted wound.

arranf commented 7 months ago

Why are you doing this?

[taxonomies]
example = []

This is a self-inflicted wound.

Yep I address this (partially) in my initial description (relevant part copied below)!

Obviously an array in taxonomies is invalid configuration however I believe this is a regression. This was not an issue in 0.112.7. After upgrading to 0.121.2 I started observing this issue occasionally as a race condition, as of 0.123.8 onwards this bug is reproducible every time hugo executes.


The root cause if it's helpful to know, is that my configuration was mistakenly set like this.

[taxonomies]
# See: https://gohugo.io/content-management/taxonomies/#default-taxonomies
disableKinds = ['taxonomy', 'term']

Whilst you're correct to say the configuration is invalid, I thought it'd be helpful to receive a bug report about a regression and at the very least anyone else who made the same error I did might save the time of debugging this themselves!

jmooring commented 7 months ago

The previous behavior wasn't great either. The right way to handle this is to make sure the plural (the right side) is a string, and error if not. But why do this for [taxonomies] and not [someotherkey] or someOtherValue? I don't see us ever fully validating the site config.

I think this is unlikely to get fixed.

agproclub commented 7 months ago

/layouts/index.html

I have used /layouts/_default/home.html

jmooring commented 7 months ago

@agproclub That is not relevant to this issue.