Skipping pages from a section in the paginator

Hello.

I am porting a site from Hugo to Zola. I am thus writing a cut down, much simpler version of the theme I used with only the features I need. I have come across a problem with the pagination and was wondering if what I am trying to do is simply not supported.

The site I have is a simple blog. I have posts. I have an about page. And that’s about it. The behavior of the site is the following:

  • if you go to www.mysite.com, you get a paginated list of the blog entries/posts, 5 at a time.
  • if you go to www.mysite.com/posts/#, where # is some number > 0, you get a paginated list of the blog entries/posts, 5 at a time.
  • if you go to www.mysite.com/posts, (notice, no numbers) you get a view of the ALL posts, grouped by year
  • otherwise, you are on a page with an actual post and reading it.

Fairly straight forward I think. I got this to mostly work using a transparent ‘posts’ sections, which allows the main content section to have all the posts, and a paginated ‘main section’ which then paginates those posts. Here is the directory structure I use:

project/content/_index.md           -> paginate_by = 5
               /posts/_index.md     -> transparent = true
                      some_post.md
                      some_other_post.md
                      ...
               /about.md
       /templates/base.html
                  about.html
                  index.html     -> used by the main "content" section, paginates
                  post.html      -> used by the posts section, groups by year
                  post-page.html

It works rather well except for one thing: the about page. That page is now an “entry” in the pagination, since it is (unsurprisingly) captured/included by the paginator as a page of the main section.

I was wondering if there is a way to exclude a page from the paginator. The thing is, I could probably relatively easily filter it out via the title, but the pagination logic would become more complicated. Imagine there are 10 blog entries and, as mentioned, I paginate by groups of 5. Then, on the second paginator, even though technically, 10 posts have been processed and there are no more posts, the paginator object would still have a next because the about page is the eleventh one. It becomes difficult to know if I should put the “more entries” link or not. Other than using the title to filter out the about page, I was also thinking I could use a supplemental transparent content level maybe (one level of indirection is always the solution… :man_shrugging:), but I believe (untested, maybe I am completely wrong) that that would make the links/permalinks/slugs wrong somehow.

Anyhow, if someone has any idea on how I could achieve what I want simply, I would appreciate it.

And as I have seen someone say it before, kudos to the person/team for the work on Zola. I got to where I am in a fairly minimal amount of time. The concepts are not overwhelming and even though the documentation is not perfect, it is very helpful and the concepts are intuitive enough that you can get results in a very reasonable amount of time. So thanks!

Yeah this is a common problem but I am not sure exactly how to solve it elegantly. My own site has the same structure as yours and I just didn’t make content/_index.md transparent and thus solves the issue since my index page is now not accumulating the blogs as well.

Maybe a exclude_from_pagination = true on a page?

Thanks for answering.

I am not sure I understand how your setup differs from mine. :confused: My content/_index.md is not transparent either, and I don’t see how to make this work without the transparent in content/posts/_index.md. Maybe I am misunderstanding something. Sorry if it’s the case.

As for introducing a variable like exclude_from_pagination = true on pages that I want excluded from the pager object, if such a hypothetical option would actually affect the pager in such a way that it would know to skip those pages, that would work perfectly for me. I haven’t pondered the ramification and I wouldn’t want to cause feature creep (I try to be mindful of that), but it would definitely solve my problem. If you mean having a variable that myself I put in there, then I am not certain how I could make that work. I guess I could crawl all the pages, count the number of pages I want to skip, but then, how to I know how many pages are left in the next pager ? Sorry for my “newbie-ness”.

Again, thanks for you answer in any case. :slight_smile:

My content/_index.md is not paginating anything: https://www.vincentprouillet.com/ all my posts are on the /blog/ url which is the one paginated

If you mean having a variable that myself I put in there, then I am not certain how I could make that work.

No, pages with that attribute would be automatically skipped when creating the pagers. I think I’ve sen that case enough times that it’s probably worth adding to Zola itself.

I get it now. Thanks.