So I want three separate loops for my posts … One to return the first two posts… other to return the third and fourth … and last to return the last two . I know the last two are the following code {{ range first 2 $paginator.Pages }}
and the last one is {{ range last 2 $paginator.Pages }}
or {{ range after 4 $paginator.Pages }}
What about the in-between pages? the following returns an error: {{ range first 2 after 2 $paginator.Pages }}
{{ $posts := (where .Site.RegularPages "Section" "==" "posts") }}
{{ $postCount := len $posts }}
<!-- {/* list only the FIRST 2 items */} -->
{{ range first 2 $posts }}
{{- partial "_posts.html" . }}
{{ end }}
<!-- {/* list all BETWEEN 2 and the (total - 2) */} -->
{{ range after 2 (first (sub $postCount 2) $posts) }}
{{- partial "_posts.html" . }}
{{ end }}
<!-- {/* list only the LAST 2 items */} -->
{{ range last 2 $posts }}
{{- partial "_posts.html" . }}
{{ end }}