Pagination can be used directly within content. You can paginate any list, not just a list of pages.
It is important to ensure that pagination is not called twice within the same physical page (i.e., make sure the pagination function is not called in the template of this page, and that it is not called more than once either in the content or in the template).
This feature has been available since version 0.1.8b. In previous versions, pagination only worked in templates.
{# The second parameter is the number of list items per page #}
{# It can be omitted — then the value from the configuration file will be used #}
{{ splitToPages(datasets.examples.movies, 10) }}
{# You can do almost anything with the list #}
{{ page.list_page | to_table(["name_en", "director_en"]) }}
{# The template should include pagination output #}
| Title | Director |
|---|---|
| Black Panther: Wakanda Forever | Ryan Coogler |
| Black Adam | Jaume Collet-Serra |
| Thor: Love and Thunder | Taika Waititi |
| Doctor Strange in the Multiverse of Madness | Sam Raimi |
| The Batman | Matt Reeves |
| Spider-Man: No Way Home | John Watts |
| Eternals | Chloe Zhao |
| Shang-Chi and the Legend of the Ten Rings | Destin Daniel Cretton |
| The Suicide Squad | James Gunn |
| Black Widow | Cate Shortland |