idarek
March 11, 2024, 6:38am
1
Hi,
The post from August 2021
I have a paginator on the home page for my blog teasers. I also have a paginator for tags. The corresponding blog teasers are also displayed there. For the tag hugo, for example, the second page has the URL https://tekki-tipps.de/en/tags/hugo/page/2 . So far so good.
Google finds fault with the correct URL for Paginator pages. By default, Hugo does not display any page information for page 2 and larger for permalinks. So I used Paginator to assemble an appropriate canonical link. This works on t…
concluded with the solution from which I took a part of a code to my site:
{{ $href := .Permalink }}
{{ with $.Paginator }}
{{ if gt .PageNumber 1 }}
{{ $href = .URL | absURL }}
{{ end }}
{{ end }}
<link rel="canonical" href="{{ $href }}">
I know that there were some breaking changes in 0.123 Hugo but unable to quicly reference it to the above code which return
execute of template failed: template: partials/head.html:50:13: executing "partials/head.html" at <$.Paginator>: error calling Paginator: pagination not supported for this page: kind: "page", path:
Any help appreciated.
idarek
March 11, 2024, 9:36am
2
Fixed replacing:
{{ with $.Paginator }}
with
{{ with and .Page.IsNode .Paginator }}
As suggested here:
opened 03:26PM - 20 Feb 24 UTC
closed 03:29PM - 20 Feb 24 UTC
Bug
NeedsTriage
Up until Hugo 0.122, you could (in a partial) check if the current page is pagin… ated like this:
```
{{- if .Page.Paginator -}}
```
Since Hugo 0.123 this is no longer possible. Instead you get this error:
> error calling Paginator: pagination not supported for this page: kind: "page"
I reckon that this could be an intended change, although it's not listed in the list of breaking changes (#11455) and so I thought to better report it.
The change could be related to #11949 but I never experienced this bug (it simply worked for me).
### What version of Hugo are you using (`hugo version`)?
<pre>
$ hugo version
hugo v0.123.0-3c8a4713908e48e6523f058ca126710397aa4ed5+extended windows/amd64 BuildDate=2024-02-19T16:32:38Z VendorInfo=gohugoio
</pre>
### Does this issue reproduce with the latest release?
Yes
Can just somebody verify that this is right approach before I click resolved?
razon
March 11, 2024, 10:51am
3
and
Returns the first falsy argument. If all arguments are truthy, returns the last argument .
Seems OK if the paginator is the last one argument.
1 Like
Be careful when using .IsNode
. It returns true when used in the 404 template (see #12162 ). And if you’re not careful you might end up doing this:
https://github.com/gohugoio/hugo/issues/12192
2 Likes
system
Closed
March 13, 2024, 1:03pm
5
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.