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.



Comments

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

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

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

Leave a Reply

Webmentions

If you've written a response on your own site, you can enter that post's URL to reply with a Webmention.

The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.

Learn more about Webmentions.