How to paginate a subdirectory?

I want templates/index.html to paginate through content/blog

.
├── content
│   ├── blog
│   │   ├── 2020-09-29-rust-optimization.md
│   │   └── 2021-01-10-dont-use-brave.md
│   ├── comments.js
│   └── main.js
├── sass
│   └── aspenuwu.scss
├── templates
│   ├── base.html
│   ├── index.html
│   └── page.html

The documentation is not clear about how to do this, though.

You can make blog a transparent = true (Section | Zola) section and set pagination on a root _index.md instead. I think it should work?

Hey there, I was trying to do the same thing and came across your question in a search. I have a similar directory structure as you:

├── config.toml
├── content
│   ├── about.md
│   └── posts
│       ├── 2021-01-05-code-debrief-thinking-of-a-number.md
│       ├── 2021-01-10-unix-pipes-and-fasting.md
│       └── _index.md

In my index.html template, I put the following code:

{% block content %}
<h2>Latest Posts</h2>
<ul>
    {% set section = get_section(path="posts/_index.md") %}
    {% for page in section.pages %}
    <li><a href="{{ page.permalink | safe }}">{{ page.title }}</a></li>
    {% endfor %}
</ul>
{% endblock content %}

With this, I was able to iterate through the lists of posts without having to use transparent = true. With your directory structure, if you changed posts to blog it should accomplish the same thing:

    {% set section = get_section(path="blog/_index.md") %}
    {% for page in section.pages %}

With my code, I was only trying to iterate through the list of blog posts rather than paginate, but I hope it may help in some way. Huge caveat, today is my first day using Zola and I do not have any experience with Rust. I’m experimenting with migrating from Hugo. Hope that helps!

I stumbled across the same problem: I have a /content/blog section also, and want templates/index.html to paginate over it. Doing a get_section(path="blog/_index.md") doesn’t get you a paginator. It has a property pages though, over which you can iterate.

The comment by Zola’s author keats with transparent = true in the _index.md located in the blog section was the most helpful one so far. Now I have a paginator. Everything seems fine. And it actually is.

But, one caveat for me: I had pages like about.md, imprint.md, etc. under /content, which are now also used for the paginator. Implementing some filter logic didn’t work, because of date and sort_by issues - leaving out some pages in the middle while having a paginate_by leads to ugly results.

I ended up with all my pages in its own section: /content/pages, which led to a cleaner template implementation.