pagination in jekyll steps
ok, this is a stupid meta-post about me fiddling around with jekyll.
i got pagination to work, and it wasn’t well documented on the jekyll site.
here’s what i had to do:
- first, needed to add the gem to my
gemfile:gem "jekyll-paginate", "~> 1.1" - if you haven’t yet, stop here and run
bundle installto make sure you’ve got the right gems installed. - next, needed to modify the
_config.yml:
plugins:
- jekyll-paginate
paginate: 5
- if you stop here, things will be working properly, but you’ll probably get an error about the lack of index.html file to paginate against.
- next, you need to create an
index.htmlfile in the main root of your blog. this file will then need to use the </code>paginator</code> code you can find on the jekyll site. - i had to stop using
index.mdthat referred to ahome.htmltemplate, and instead move most of the template code into my index.html file. - i also had to add some stupid control logic to the
header.htmlinclude file i am using to make sure it didn’t put “home” in the header 3 times (one for each pagination, i think). here’s what i did in all of its shitty glory:{%- if my_page.title -%} {%- if my_page.title != "home" or my_page.title == 'home' and home_count == 0 -%} {{ my_page.title | escape }} {%- endif -%} {%- if my_page.title == "home" -%} {%- assign home_count = 1 -%} {%- endif -%} {%- endif -%}