Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I iterate over the posts of a section using Zola?

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 %}
like image 669
6754534367 Avatar asked Sep 06 '25 03:09

6754534367


1 Answers

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.

like image 89
6754534367 Avatar answered Sep 07 '25 20:09

6754534367