Download

@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

What are you waiting for?

Start building your site today.

  1. 1 Download Publii
  2. 2 Write your content
  3. 3 Publish your site
Create website