pagination plugin

2019-05-23

how to use pagination plugin for jekyll project's pagination.

outline

jekyll basically provides pagination plugin but we use jekyll-paginate-v2. this blog introduces how to use jekyll-paginate-v2.

plugin installation and configuration

install and configure jekyll-paginate-v2.

plugin installation

install jekyll-paginate-v2 plugin with below code.

gem install jekyll-paginate-v2

plugin configuration

write below contents to _config.yml file.

plugins:
  - jekyll-paginate-v2

permalink: /:year/:month/
pagination:
  enabled: true
  per_page: 12
  sort_reverse: true
  sort_field: 'date'
  title: ':title'
  trail:
    before: 2
    after: 2
  • permalink: this is page default link. if this is not set, plugin is not working.
  • pagination: these are plugin options. if you want more informations, see officail site.(jekyll-paginate-v2:options)
  • enabled: activate plugin.
  • per_page: post count per page.
  • sort_reverse: indicates whether to reverse sort. we set `true` for newest.
  • sort_field: plugin uses the field when sort. we use date field to show latest posts.
  • title: the title of the page created by pagination. this option will set page.title variable.(ex> :title - page :num)
  • trail: before/after pagination count of selected page.

page configuration

configurations are for showing pagination. page which has pagination and page which will be called from pagination page need to be configured.

pagination page

set below code to the page which has pagination.(ex> category pages)

pagination:
  enabled: true
  category: 'jekyll'
  permalink: '/:num/
  • enabled: activate pagination.
  • category: posts in this category will be paginated.
  • permalink: the url of pages created by pagination feature.(ex> /:num/)

pages called from pagination

configure below option to the pages called from pagination.(ex> post page)

paginate_path: '/jekyll/:num/pagination-plugin/'
  • paginate_path: options for including page number in the url of the page called from pagination.

reference

Buy me a coffeeBuy me a coffee
Posts