I create my own content designs under the Layout folder. Then I add content to these folders under the content folder. I add more than one content to a folder and display all the content using pagination.
To make pagination, I need to create a pagination structure for each folder while creating my designs under the Layout folder and I do this with the code below.
{{ $pages := (.Paginate (where site.RegularPages "Section" "webmaster") ).Pages }}
{{ $paginator := .Paginate ($pages) }}
{{ range $paginator.Pages }}
{{ $title := .Title }}
{{ $summary := .Summary }}
<section class="item">
<div>
<h1 class="title"><a href='{{ .RelPermalink }}'>{{ $title }}</a></h1>
</div>
<div class="summary">
<p>{{ $summary }}</p>
</div>
</section>
{{ end }}
{{ if or ($paginator.HasPrev) ($paginator.HasNext) }}
<div class="pagination">
{{ if $paginator.HasPrev }}
<span class="prev">
<a href="{{.Paginator.Prev.URL}}">
<span class="arrow">ā</span>
</a>
</span>
{{ end }}
{{ if $paginator.HasNext }}
<span class="next">
<a href="{{.Paginator.Next.URL}}">
<span class="arrow">ā</span>
</a>
</span>
{{ end }}
</div>
{{ end }}
I have explained so far for informational purposes, I do not have any problem with what I have described above.
But I want to add these tags in the SEO section if there is pagination. If there is no pagination, these codes should not be added. So I need to check this with the if structure.
<link rel="prev" href="{{ .Paginator.Prev.URL | absURL }}">
<link rel="next" href="{{ .Paginator.Next.URL | absURL }}">
The problem is that I canāt check if there is pagination on the page. Unfortunately I couldnāt do it because I checked the SEO tags in another file and called them in with partical.
I canāt check because the following code changes on each page.
{{ $pages := (.Paginate (where site.RegularPages "Section" "webmaster") ).Pages }}
I canāt do it for some reason because this code has changed. I wanted to ask here in case there might be a parameter I donāt know etc. I would appreciate it if you help.
If you do not understand my question, if you ask where you do not understand, I will try to explain it in a simpler way