I`m trying to make rel links in <head:
<lnk rel=“prev” href=“part1.html”
<lnk rel=“next” href=“part3.html”
but when i try to access .Paginator i get error
ERROR 2018/05/24 12:37:41 Error while rendering “home” in “”: template: C:\Hugo\www.example.com\themes\theme\layouts_default\list.html:6:33: executing “main” at <.Paginate>: error calling Paginate: a Paginator was previously built for this Node without filters; look for earlier .Paginator usage
as i told befote when i try to access .Paginator from header i get error
i think thats because i`m using custom pagination further in code, but i need it too )
<!-- ROBOTS POSTS INDEX -->
{{ if $.Scratch.Get "blogs" }}
{{ $paginator := .Paginate (where .Data.Pages "Type" "article") 6 }}
{{ if not $paginator.HasPrev }}
<meta name="robots" content="index, follow">
{{ else }}
<meta name="robots" content="noindex, follow" />
{{ end }}
{{ if $paginator.HasPrev }}
<link rel="prev" href="{{ .Paginator.Prev.URL }}" />
{{ end }}
{{ if $paginator.HasNext }}
<link rel="next" href="{{ .Paginator.Next.URL }}" />
{{ end }}
{{ end }}
this is part where the list.html or pagination part
<!-- I move this part into my head
{{ $paginator := .Paginate (where .Data.Pages "Type" "article") 6 }}
-->
{{ range $paginator.Pages }}
....your index here
As you can see I move the part of paginator {{ $paginator := .Paginate (where.... to the head
That`s helped a lot, but there was few errors, which i already fixed.
First one resolved by adding “$paginator := .Paginate …” func one more time in list.html
Second one is about Paginator doesn’t work for Kind page
So the final code is:
head-meta.html
{{if eq .Kind "taxonomy"}}
{{ $paginator := .Paginate (where .Data.Pages "Type" "skin") (index .Site.Params "paginate" | default 10) }}
{{ if $paginator.HasPrev }}
<link rel="prev" href="{{ .Paginator.Prev.URL }}" />
{{ end }}
{{ if $paginator.HasNext }}
<link rel="next" href="{{ .Paginator.Next.URL }}" />
{{ end }}
{{ end }}