True Ghost Numeric Pagination

Note: This is entirely undocumented functionality. It may well break in the future. However, it currently works as of v2.1.2. As such, this post only explains enough that you can implement it if you know what you're doing.

If you want true numbered pagination in your blog, and you're using Ghost, it's impossible out of the box. The problem is, if you've got a lot of posts, you run into the SEO problems introduced by long chains of pagination. Here's how you solve that:

Firstly, navigate to and open /current/core/server/models/plugins/pagination.js

Now find the formatResponse function, and in the pagination object, add the following key/value to it:


Shortly below, in the if pagination.pages > 1 block, add the following loop:

for (var i = 1; i <= pagination.pages; i++)
    pagination.pageList.push(i ===

This creates a new attribute that you can access in your pagination template, called pageList. That attribute is an array of true/false values. Each item corresponds to the list of paginated pages available, with the value set based on whether or not that page is the current one being viewed.

I use it with the following code:

<nav role="pagination" id="pagination">
	{{#foreach pageList}}
		{{#if this}}
		<li><a class="current">{{@number}}</a></li>
		<li><a href="{{page_url @number}}" class="{{@class}}">{{@number}}</a></li>

This creates numbered pagination, avoiding making a link of the page you're currently on.

If you've enjoyed this post, you might want to follow our founder, Pete Watson-Wailes on Twitter