The Ghost Themes Developer Hub

Welcome to the Ghost Themes developer hub. You'll find comprehensive guides and documentation to help you start working with Ghost Themes as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

pagination

{{pagination}} Helper - Output a pagination block

Usage: {{pagination}}

Type
Parameters
Attributes

Description

{{pagination}} is a template driven helper which outputs HTML for 'newer posts' and 'older posts' links if they are available and also says which page you are on.

You can override the HTML output by the pagination helper by placing a file called pagination.hbs inside of content/themes/your-theme/partials. Details of the default template are below.

The data used to output the {{pagination}} helper is generated based on the post list that is being output (index, tag posts, author posts etc) and always exists at the top level of the data structure.

Misusage of the pagination helper

If you are using the pagination outside of the data context, you will receive an error. Ensure you are using the helper within the resource output.

Pagination Attributes

  • page - the current page number
  • prev - the previous page number
  • next - the next page number
  • pages - the number of pages available
  • total - the number of posts available
  • limit - the number of posts per page

Default Template

The default template output by Ghost is shown below. You can override this by placing a file called pagination.hbs in the partials directory of your theme.

<nav class="pagination" role="navigation">
    {{#if prev}}
        <a class="newer-posts" href="{{page_url prev}}">&larr; Newer Posts</a>
    {{/if}}
    <span class="page-number">Page {{page}} of {{pages}}</span>
    {{#if next}}
        <a class="older-posts" href="{{page_url next}}">Older Posts &rarr;</a>
    {{/if}}
</nav>

Changing posts_per_page

Looking to change how many items are output? Take a look at the new posts_per_page config - {{pagination}} is an output helper only, and cannot affect how many items appear on a page.

pagination

{{pagination}} Helper - Output a pagination block