Hiding Categories from the Jekyll Paginator, Unless, and Insert statements

Today I learned:

Hiding Categories from Paginator

According to the Jekyll docs, the jekyll-paginator plugin does not support categories or tags. That means there is no way to exclude a category as a whole. You can only exclude posts individually by including hidden: true in each post’s YAML front-matter.

I’m hiding all of my TIL posts from the front page of my site, so I did a global find and replace to accomplish it.

Mirror of If statement in Liquid

Liquid has a neat concept that is the inverse of an If statement. It executes if a condition is not met.

{% unless post.categories contains 'TIL' %} 	Code here to display all the things! {% endunless %}

Inserting via mysqli()

Using the mysqli() function I wrote about yesterday, here is how to insert something into a table:

 $connect = new mysqli($server, $db_username, $password, $db); $connect->query("INSERT INTO `table_name` (username) VALUES ('$user');");

Make sure your variables are sanitized first! You don’t want someone doing a SQL injection.

Eric Davis told me that mysqli() is the old way of doing things and I should check out PDO instead.


2 responses to “Hiding Categories from the Jekyll Paginator, Unless, and Insert statements”

  1. utu Avatar
    utu

    Using hidden:true hides the post from category pages using Jekyll-Paginate-v2.

    1. utu Avatar
      utu

      Sorry. I mean using this method affects the number of posts shown per page.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: