Comments and Pagination

12 Dec 2013

Now that I've done further, most likely unnoticable, refinements to this site, I have been tossing the idea around of adding a comments section to each of the permalinked posts. There seem to be a fair number of static comment plugins already available, so it sounds like it would be brain dead easy to add something simple in. I'm going to avoid complicated things like Disqus since it seems like overkill for the "whopping amount" of traffic this website generates. I will continue looking into more static solutions, since it would make it harder for this place to just become a nest for spam bots.

In other news I've implemented/fixed pagination for this site, using Jekyll's built in pagination. I've technically had the code there the whole time, but since I had less than 5 posts up until now, it didn't do anything. It was broken anyways due to previous looking for page1/, which is not generated by my configuration. All that was needed was an addition if-else clause with Liquid, and everything works as intended. It's such a simple fix that I don't even know why Jekyll includes the broken example on their page.

For the curious out there, here's my version:

index.html

<div class="pagination">
  {% if paginator.previous_page %}
    {% if paginator.previous_page == 1 %}
      <a href="/">Previous</a>
    {% else %}
      <a href="page{{ paginator.previous_page }}">Previous</a>
    {% endif %}
  {% else %}
    <span>Previous</span>
  {% endif %}
  <span>Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
  {% if paginator.next_page %}
    <a href="page{{ paginator.next_page }}">Next</a>
  {% else %}
    <span>Next</span>
  {% endif %}
</div>

And that's really all it takes. I also tried the overly complicated fix they have listed below, and fought with it far more than I should have (as in I had to fight with it at all), and just settled on my slight modification instead. Sure, I could have had links to multiple pages instead of just having "next" and "previous", but who cares? That's what the archives are for!

Comments