GitHub

@pagination global variable

Homepage, tag, and author pages support pagination. It is based on a few global variables and helpers. You can use pagination not only for creating pagination links, but also for a link with rel="prev" or rel="next" attributes.

  • @pagination - variable used to detect if pagination is available in the specific view. If false - there is no pagination in the current view,
  • @pagination.context - context of the pagination. Empty string for homepage, tag slug for tag pages, author slug for author pages,
  • @pagination.pages - array with numbers for each available page,
  • @pagination.totalPosts - total number of posts,
  • @pagination.totalPages - total number of pagination pages,
  • @pagination.currentPage - number of the current page,
  • @pagination.postsPerPage - number of posts per page,
  • @pagination.nextPage - number of the next page (or false if none exist),
  • @pagination.previousPage - number of the previous page (or false if none exist),
  • @pagination.nextPageUrl - URL to the next page (or false if none exist),
  • @pagination.previousPageUrl - URL to the previous page (or false if none exist).

An example of pagination for search engines with use of the global pagination variables:

{{#if @pagination}}
   {{#if @pagination.previousPage}}
   <link rel="prev" href="{{@pagination.previousPageUrl}}">
   {{/if}}
   {{#if @pagination.nextPage}}
   <link rel="next" href="{{@pagination.nextPageUrl}}">
   {{/if}}
{{/if}}

An example of a pagination link is available in Partials -> pagination.hbs

Subscribe

Get the latest Publii news, updates and more delivered directly to your email inbox

You can change your mind at any time by clicking the unsubscribe link in the footer of any email you receive from us, or by contacting us at contact@tidycustoms.net. By clicking below, you agree that we may process your information in accordance with our Privacy Policy.