At some point the pagination in my blog got broken. I suspect that’s because I installed custom theme and it messed up something, but I’m not sure. Anyway, the link ← Older in the bottom of the front page directed to /2 instead of posts/2.

And that’s how I’ve managed to fix it.

First I checked /_config.yml:

...
paginate: 10          # Posts per page on the blog index
paginate_path: "posts/:num"  # Directory base for pagination URLs eg. /posts/2/
...

So, everything is correct here. I stumbled upon a couple of possible solutions suggesting to change from posts/:num to blog/posts/:num, but in my case that wasn’t the reason. Anyway, if it worked before, why change it now? So, the problem is somewhere in templates.

No matter how strange it might sound, but I found solution on the Jekyll documentation page about pagination, who would have even thought about looking for it there. Anyway, I saw this expression:

paginator.next_page_path

but in my template it was:

paginator.next_page

And the same for paginator.previous_page.

So I changed my /source/index.html like this:

...
<div class="pagination">
    {% if paginator.next_page %}
        <a class="prev" href="{{paginator.next_page_path}}">← Older</a>
    {% endif %}
    <a href="/blog/archives">Blog Archives</a>
    {% if paginator.previous_page %}
        <a class="next" href="{{paginator.previous_page_path}}">Newer →</a>
    {% endif %}
</div>
...

And now pagination works as it should.

I have also changed the name of the blog - now it’s called “Declaration of VAR”. Just how genius is it, right?