3

I tried the following, which I found in the Zola documentation but it didn't render anything. The Tera docs weren't rewarding either.

{% for post in section.pages %}
  <h1><a href="{{ post.permalink }}">{{ post.title }}</a></h1>
{% endfor %}
6754534367
  • 5,123
  • 4
  • 17
  • 24

1 Answers1

2

The correct way to iterate over a paginated section is as following:

{% for post in paginator.pages %}
  <h1><a href="{{ post.permalink }}">{{ post.title }}</a></h1>
{% endfor %}

paginator is described in the Templates section under Pagination: getzola.org/documentation/templates.

A paginated section gets the same section variable as a normal section page minus its pages. The pages are instead in paginator.pages.

6754534367
  • 5,123
  • 4
  • 17
  • 24
  • 1
    Could you explain a little more about what is the difference? Is `paginator` a special term in Zola or is it a variable in your code? – Peter Hall Apr 11 '19 at 21:52
  • @PeterHall I'm unsure, I've been delving into Zola/Tera and this is what I came up with after checking out how a working theme managed to do it: https://github.com/shalzz/butler/blob/master/templates/blog.html I think it has to do with the fact it's a 'paginated' section but I can't find 'paginator' in any of the docs... – 6754534367 Apr 12 '19 at 06:07
  • 1
    `paginator` is described in the Templates section under Pagination: https://www.getzola.org/documentation/templates/pagination/ – CodeManX Jan 14 '20 at 11:01