Search code examples
hugohugo-shortcode

Using multiple .Paginate ranges with Hugo


I'm struggling in creating multiple ranges using hugo.

 {{ range (.Paginate (where site.RegularPages "Section" "research")).Pages }}
    {{ partial "research-card" .}}
  {{ end }}

  {{ range (.Paginate (where site.RegularPages "Section" "services")).Pages }}
       {{ partial "services-card" .}}
  {{ end }}

I want to use each of these to create cards for different sections however they are in the same html file. The issue I am having is that when I add the second range it removes the cards from the first one and if I create pages for each I get nil variable errors.

Is there a way to use more than one range on the same page in hugo to create a home page that loads different sections?


Solution

  • The error message is pretty clear: It is not supported with two paginagors on one page, “/page/1” then … what do we do with the second? We may make some magic in this department in the future, but that is a big maybe. You will have to figure a way to exclude one or both of the paginators.

    Says Bjørn Erik Pedersen here.