How to show range with paginator partial on single page templates

Hello all,
So i have this partial in partials/blog-cards/bid-blog-card.html

<div class="single-card-layout two-card-layout">
    {{ $paginator := .Paginate (where .Site.Pages "Params.type" "blog") }}
    {{ range first 1 $paginator.Pages }}    
    <div class="single-card">
            <div class="single-card__bg-img">
                <div class="single-card__bg-img-inner" style="background:url('{{ .Params.image | relURL}}') center center; background-size:cover;">
                <div class="date-holder">
                    <span>{{ .Lastmod.Format "January 2, 2006" }}</span>
            <div class="single-card-body">
                <div class="single-card-body__tags">
                    {{ range (.GetTerms "categories") }}
                    <a class="single-card-body__tags-link" href="{{ .Permalink }}">{{ .LinkTitle }}</a>
                    {{ end }}
                <a  href="{{ .Permalink }}" class="single-card-body__title" href="">{{ .Title}}</a>
                <div class="single-card-body__description">
                    {{ .Content | truncate 250 }}
        {{ end }}

When i import this in index.html it works fine but when i import this in any other pages it gives an error -

render of "page" failed: execute of template failed: template: home-sidebar-design-two/single.html:10:28: executing "main" at <partial "blog-cards/single-big-card.html" .>: error calling partial: "-/layouts/partials/blog-cards/single-big-card.html:3:31": execute of template failed: template: partials/blog-cards/single-big-card.html:3:31: executing "partials/blog-cards/single-big-card.html" at <$paginator.Pages>: error calling Pages: runtime error: invalid memory address or nil pointer dereference
Rebuild failed:

Also i found out that you can not use paginator on other single page templates.

So how can i show list of blogs on other single page templates ?

What is the issue and please guide with the solution.


This feature is currently only supported on homepage and list pages (i.e., taxonomies and section lists).

Iā€™m not sure why you are paginating anyway, since you are limiting the output to the first 1.

hi, first 1 was for a testing purpose. Please ignore

so can you guide me if i want to show list of blog on other single page template for ex say about-us page. how can we do that ?

{{ range where .Site.RegularPages "Type" "blog" }}
  <a href="{{ .RelPermalink }}">{{ .Title}}</a><br>
{{ end }}

okay got it so no pagination

one last thing, how can we use after 1 in this

{{ range first 9 (where .Site.Pages "Params.type" "blog") }}

{{ range first 9 (after 1 (where .Site.Pages "Params.type" "blog")) }}

thank you so much @jmooring . Appreciate all the help from your side

1 Like

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