gohugoio / hugo

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

.IsNode is true for 404.html #12162

Open skrysmanski opened 7 months ago

skrysmanski commented 7 months ago

As discussed here, .IsNode should be false for the 404.html template.

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

$ hugo version
hugo v0.123.3-a75a659f6fc0cb3a52b2b2ba666a81f79a459376+extended linux/amd64 BuildDate=2024-02-23T17:09:20Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

skrysmanski commented 7 months ago

I think the primary question here is: What does .IsNode actually mean.

The documentation simply states:

Reports whether the given page is a node.

What exactly makes a page a node? (Or: What exactly is a node, semantically?) Is this documented somewhere?

My interpretation is that a "node page" is a collection of pages. But this would not apply to the 404, or would it?

jmooring commented 7 months ago
{{ .Kind }}       --> 404 (correct)
{{ .Type }}       --> page (correct)

{{ .IsHome }}     --> false (correct)
{{ .IsSection }}  --> false (correct)

{{ .IsNode }}     --> true (??)
{{ .IsPage }}     --> false (??)

I learned yesterday that the 404 template receives a Pages collection in context (seems to be equivalent to Site.Pages), and you can paginate within this template. So in that sense it is a "node". Having said that, I don't know why it receives pages in context, and the ability to paginate within this template is new in v0.123.0 (which lead to https://github.com/gohugoio/hugo/issues/12192).

See also https://github.com/gohugoio/hugo/issues/11574.