I've noticed that while paginating over a collection the count starts at 0. Is this normal?
If so, is there a way of starting the count at 1? I consider the top level page to be page 1, then you click next and view page 2.
Example folder and url structure:
/blog
/blog/2
/blog/3
/blog/4
This would mean you could display the pagination like below and your url structure would match - Github pagination follows the same pattern:
The user is viewing /blog (Page 1).
Pagination is the following:
Previous (disabled)
1 (active)
2 (clickable)
3 (clickable)
4 (clickable)
Next (clickable)
Whats' the best way to achieve this?
Should this behaviour be the default implementation?
I can imagine that it might be because „Arrays start with 0” (a heated debate among computer scientists).
There is an example of this on the docs (almost!)
https://www.11ty.io/docs/pagination/#remapping-with-permalinks
permalink: blog/{{ pagination.pageNumber + 1 }}/index.html
---
You can also use template logic here to get the full working example:
permalink: blog/{% if pagination.pageNumber > 0 %}{{ pagination.pageNumber + 1 }}/{% endif %}index.html
---
Added a few more docs for this too https://www.11ty.io/docs/pagination/#remapping-with-permalinks
Amazing! Thanks for your help!
Most helpful comment
There is an example of this on the docs (almost!)
https://www.11ty.io/docs/pagination/#remapping-with-permalinks
You can also use template logic here to get the full working example: