Pagination across sections

I have 3 sections in my blog. With my pager template, the next and previous only move in the current section.

What I’m trying to do is for it to move across 3 sections.

Here is the template:

{{- if .Param "pager" }}
{{- if or (.PrevInSection) (.NextInSection) }}
<nav class="pager flex">
	{{- if .PrevInSection }}
	<div class="pager__item pager__item--prev">
		<a class="pager__link" href="{{ .PrevInSection.RelPermalink }}" rel="prev">
			<span class="pager__subtitle">«&thinsp;{{ T "post_nav_prev" }}</span>
			<p class="pager__title">{{ .PrevInSection.Title }}</p>
	{{- end }}
	{{- if .NextInSection }}
	<div class="pager__item pager__item--next">
		<a class="pager__link" href="{{ .NextInSection.RelPermalink }}" rel="next">
			<span class="pager__subtitle">{{ T "post_nav_next" }}&thinsp;»</span>
			<p class="pager__title">{{ .NextInSection.Title }}</p>
	{{- end }}
{{- end }}
{{- end }}

Thank you

You can do something ala:

{{ $prev := site.RegularPages.Prev . }}
{{ $next := site.RegularPages.Next . }}
... and then replace .PrevInSection and .NextInSection with the above 2 vars

Thank you. It worked!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.