Hugo

Pagination outside of index.html

Hello everybody, new to the forum here :slight_smile:

I’m trying to convert a design I made with Html and CSS into my own hugo theme and I am encountering a problem with pagination:
I have in may theme, in the layouts a page folder that contains a blog page. I want to display here a list of 6 blog posts with just image and excerpt plus a link to the actual post.
I manage to do all of that and now I am trying to implement pagination so that if there are more than 6 posts you can move on to the next 6.
I was trying to get the code right for a while before i tried it in a different page (index.html) and found out it was working fine.
I tried putting it into a partial but whenever I call it from the blog page I get a NIL reference.
Is this because the blog page is not in the root folder? Does pagination only work in the Index? can it be adapted for my purposes?

Thank you very much for your help :slight_smile:

As with most coders, it is often easier to see an example. Can you please upload a sample project on GitHub in order to visualize this problem and understand the code that you’re using? Otherwise, it will be near impossible to help you solve the problem.

As for Pagination, per the documentation:

.Paginator is provided to help you build a pager menu. This feature is currently only supported on homepage and list pages (i.e., taxonomies and section lists).

Therefore when using pagination in a partial, you’ll want to make sure you’re only using the partial on those pages.

1 Like

Hi, thank you for your reply, I appreciate it.
So does it work only on the lists in the _default folder or any list page in any folder as far as you know?

I actually managed to sort it out Thank you! All i needed to do is change my blog page to a list page and put it in the blog folder :slight_smile:

1 Like