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

Build fails on hugo v0.123: pagination not supported for this page: kind: "page" #169

Closed
alexishuf opened this issue Feb 21, 2024 · 8 comments · Fixed by #171
Closed

Build fails on hugo v0.123: pagination not supported for this page: kind: "page" #169

alexishuf opened this issue Feb 21, 2024 · 8 comments · Fixed by #171

Comments

@alexishuf
Copy link

Poison site does not build with hugo 0.123.0 and 0.123.1, but builds with v0.122.0

Steps to reproduce:

hugo new site test
cd test
git clone --depth=1 https://github.com/lukeorth/poison themes/poison
# add minimal config to hugo.toml:
cat >>hugo.toml <<EOF
theme = 'poison'

[params]
brand = 'my_brand'
menu = [
  {Name = "About", URL = "/about/", HasChildren = false},
  {Name = "Posts", URL = "/posts/", HasChildren = true, Limit = 5},
]
EOF
hugo new content posts/hello/index.md
hugo -D

Outputs:

Start building sites …
hugo v0.123.0+extended linux/amd64 BuildDate=unknown

Total in 49 ms
Error: error building site: render: failed to render pages: render of "page" failed: "/home/alexis/sources/test/themes/poison/layouts/_default/baseof.html:1:3": execute of template failed: template: _default/single.html:1:3: executing "_default/single.html" at <partial "head/head.html" .>: error calling partial: "/home/alexis/sources/test/themes/poison/layouts/partials/head/head.html:16:7": execute of template failed: template: partials/head/head.html:16:7: executing "partials/head/head.html" at <partial "head/meta.html" .>: error calling partial: "/home/alexis/sources/test/themes/poison/layouts/partials/head/meta.html:96:17": execute of template failed: template: partials/head/meta.html:96:17: executing "partials/head/meta.html" at <.Paginate>: error calling Paginate: pagination not supported for this page: kind: "page", path: "/posts/hello", file: "/home/alexis/sources/test/content/posts/hello/index.md"

the issue happens without -D, provided draft = true is changed at hello/index.md

The relevant code in layouts/partials/head/meta.html:

<!-- Pagination meta tags for list pages only -->
{{ $paginator := .Paginate (where .Pages "Type" "posts") }}
{{ if $paginator }}
  <link rel="first" href="{{ $paginator.First.URL }}" />
  <link rel="last" href="{{ $paginator.Last.URL }}" />
  {{ if $paginator.HasPrev }}
    <link rel="prev" href="{{ $paginator.Prev.URL }}" />
  {{end }}
  {{ if $paginator.HasNext }}
    <link rel="next" href="{{ $paginator.Next.URL }}" />
  {{end }}
{{end }}

Deleting this code gets the build to complete.

gohugoio/hugo#11954, merged into hugo 0.123.0 might be related. My understanding of hugo is limited and as there was no issue reported on the hugo repo yet, it could be a poison issue.

@x-zvf
Copy link

x-zvf commented Feb 23, 2024

I am encountering the same issue.. :(

@sudomateo
Copy link
Contributor

sudomateo commented Feb 25, 2024

Also encountering this issue. Found a nice blog post about it at https://www.irisclasson.com/2024/02/21/hugo-error-calling-paginator/.

For now I made the following change to override the layout.

diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html
index 691f114..cb9c888 100644
--- a/layouts/partials/head/meta.html
+++ b/layouts/partials/head/meta.html
@@ -92,18 +92,6 @@
 <!-- Article Specific Tags -->
 <!-- To make sure this renders only in the article page, we check the section -->
 {{ if eq .Section "posts" }}
-<!-- Pagination meta tags for list pages only -->
-{{ $paginator := .Paginate (where .Pages "Type" "posts") }}
-{{ if $paginator }}
-  <link rel="first" href="{{ $paginator.First.URL }}" />
-  <link rel="last" href="{{ $paginator.Last.URL }}" />
-  {{ if $paginator.HasPrev }}
-    <link rel="prev" href="{{ $paginator.Prev.URL }}" />
-  {{end }}
-  {{ if $paginator.HasNext }}
-    <link rel="next" href="{{ $paginator.Next.URL }}" />
-  {{end }}
-{{end }}

 <meta property="og:type" content="article" />
 <meta property="article:publisher" content="{{ .Site.Params.facebook_url }}" />

sudomateo added a commit to sudomateo/website that referenced this issue Feb 25, 2024
There's an issue with the upstream theme on Hugo v0.123 that prevents
the site from building.
- lukeorth/poison#169
glasser added a commit to glasser/vote.davidglasser.net that referenced this issue Feb 25, 2024
@ctmbl
Copy link
Contributor

ctmbl commented Mar 10, 2024

I have no clue neither if this bug is really from hugo or poison, given gohugoio/hugo#11949 and gohugoio/hugo#12080 I'd say poison though, hugo maintainers seem to stick with their changes.

Anyway I cloned hugo's repo and using git bisect managed to identify the commit introducing (or triggering) this behavior:
gohugoio/hugo@6c3b6ba
I'm not used to hugo's code so I don't know if I'll do something of it but here it is if someone needs it

also AmazingRise/hugo-theme-diary#177 (comment) seems to be a fix, don't really know if this applies well to poison though

@FLopriore
Copy link
Contributor

also AmazingRise/hugo-theme-diary#177 (comment) seems to be a fix, don't really know if this applies well to poison though

I applied this fix and it compiles successfully.

Replace line 94 in layouts/partials/head/meta.html:
{{ if eq .Section "posts" }}
with:
{{ if and (eq .Section "posts") (.Page.IsNode) }}

sudomateo added a commit to sudomateo/website that referenced this issue Mar 14, 2024
There's an issue with the upstream theme on Hugo v0.123 that prevents
the site from building.
- lukeorth/poison#169
sudomateo added a commit to sudomateo/website that referenced this issue Mar 14, 2024
There's an issue with the upstream theme on Hugo v0.123 that prevents
the site from building.
- lukeorth/poison#169
ctmbl added a commit to ctmbl/poison that referenced this issue Mar 18, 2024
patch proposed by: FLopriore
issue: lukeorth#169
@ctmbl
Copy link
Contributor

ctmbl commented Mar 18, 2024

@FLopriore it seems to fix it, could you propose a PR to the repo?

@FLopriore
Copy link
Contributor

@FLopriore it seems to fix it, could you propose a PR to the repo?

Yes, I do it right now

FLopriore added a commit to FLopriore/poison that referenced this issue Mar 18, 2024
It fixes issue lukeorth#169: Build fails on hugo v0.123: pagination not
supported for this page: kind: "page".
See kLiHz's comment in AmazingRise/hugo-theme-diary#177.
@lukeorth
Copy link
Owner

Thanks, everyone! Sorry for being MIA the past several weeks. PR is merged. 👍

@lukeorth lukeorth linked a pull request Mar 18, 2024 that will close this issue
@sudomateo
Copy link
Contributor

Thank you! Updated my website to the latest version and it's working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants