Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 page treated as paginated #12192

Closed
earthboundkid opened this issue Mar 1, 2024 · 5 comments
Closed

404 page treated as paginated #12192

earthboundkid opened this issue Mar 1, 2024 · 5 comments

Comments

@earthboundkid
Copy link
Contributor

Building my site with Hugo 0.123.7 results in a /404/ directory being created with 99 entries, as though it were paginated.

See #12174.

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

$ hugo version
hugo v0.123.7-312735366b20d64bd61bff8627f593749f86c964+extended darwin/arm64 BuildDate=2024-03-01T16:16:06Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes.

@jmooring
Copy link
Member

jmooring commented Mar 2, 2024

I have no idea how to reproduce this. Can you please provide an example?

@earthboundkid
Copy link
Contributor Author

earthboundkid commented Mar 2, 2024

Clone https://github.com/spotlightpa/poor-richard. Run yarn. Run hugo. Look at the public/404/ directory.

@jmooring
Copy link
Member

jmooring commented Mar 2, 2024

1) layouts/_default/baseof.html calls layouts/partials/helper/paginator.html.

2) layouts/partials/helper/paginator.html paginates if Page.IsNode is true.

3) Page.IsNode is true for page kind 404. It has been that way since v0.54.0 (maybe earlier). Whether the return value makes sense is debatable; see #12162.

So, the partial says, "Paginate this thing," which obviously doesn't make any sense for a 404 page. We'll get to why things changed in a minute, but you should exclude page kind 404 from pagination by changing this:

{{ if .IsNode }}

To this:

{{ if and .IsNode (ne .Kind "404") }}

4) This should have been happening with v0.122.0 and earlier. Why wasn't it?

  • In both versions the .Pages collection passed into the 404 template seems to be equivalent to Site.Pages. I don't understand why the 404 template needs a .Pages collection, but that's another topic. The fact that there is a Pages collection means the the Paginator method can act upon something.
  • In v0.122.0 and earlier, calling the Paginator method within a 404 template didn't do anything. Now it does.

It looks like we fixed (either directly or indirectly) the Paginator method in v0.123.0 when called from the 404 template, and that change exposed the conditional logic problem in the partial.

@earthboundkid
Copy link
Contributor Author

Okay, sounds like this one can be closed. I will take a look Monday.

@jmooring jmooring closed this as completed Mar 2, 2024
earthboundkid added a commit to spotlightpa/poor-richard that referenced this issue Mar 20, 2024
earthboundkid added a commit to spotlightpa/poor-richard that referenced this issue Mar 20, 2024
earthboundkid added a commit to spotlightpa/poor-richard that referenced this issue Mar 21, 2024
earthboundkid added a commit to spotlightpa/poor-richard that referenced this issue Mar 21, 2024
* Reapply "Fixes for Hugo v123 (#595)" (#607)

This reverts commit ed05f10.

* More fixes for Hugo v123


See gohugoio/hugo#12174 gohugoio/hugo#12191 gohugoio/hugo#12192

* netlify.toml: Bump Hugo to 124.1

* Yarn upgrades

* yarn: Upgrade postcss-cli
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants