Paginate Correlated Content from Two Sections

I have a site that looks like this:


  • list.html
  • li.html
  • single.html


  • list.html
  • li.html
  • single.html


On the collections single.html, I am trying to paginate products that have the same id.

I am unable to make this happen. Does anyone have an example of something similar to this?

Here is the code I have now that shows all the products that have the same as the collections .Params.collection_id:

      {{ $collection_id := }}
      {{ $products := where $.Site.RegularPages "Type" "product" }}

      {{ range $products }}
        {{ if eq .Params.collection_id $collection_id }}

        {{ .Render "li" }}
        {{ end }}
      {{ end }}

How can I paginate through this content on this page, but use the layouts/products/li.html on this layouts/collections/single.html template?

First, pagination is not available from single page templates:

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

Second, it seems like Hugo’s taxonomy system would handle most of this for you. Try it:

git clone --single-branch -b hugo-forum-topic-36496 hugo-forum-topic-36496
cd hugo-forum-topic-36496
hugo server

In this example:

  • Products 01-30 are members of Collection A
  • Products 31-60 are members of Collection B
  • Products 61-70 are members of both collections
  • The collection (term) pages are paginated (layouts/term/collection.html)
  • The collection (term) pages render each product using a content view (layouts/products/li.html)
1 Like

Thank you @jmooring - this is the path I was leaning toward taking.

Thank you very much!

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