Previous and Next Posts ─ Posts with Numbers: 10 jumps to 100

Hello everybody,

I’m facing a weird issue here.

I’m creating a online version of a book and I want to name the urls with the number of the page like so: /page-01, /page-02, /page-03…

Inside each page I’m using {{ page.previous.url }} and {{ page.next.url }} to create navigation between the pages.

When navigated to /page-10, the next page url that appear is /page-100 instead of /page-11

I’ve searched a lot on Google to find something on StackOverflow but anything solved my problem.

Do you know some hack to get rid of this?

Thanks in advance

“10”,“100”,“11” are strings sorted alphanumerically, as well as “010”, “011”, “100”.

You just have to rename your first 99 pages to “page-001”, …, “page-099”, “page-100”.

or if it will ever get to 1000 then 0001, 0002… etc. Same number of digits for all numbers, using leading zeroes to pad the lower numbers.