Exclude the particular categories

Can we exclude the particular posts categories using if or else statement?

Not real clear what you mean.
First google result for jekyll exclude category:


Do you mean to exclude posts completely from the site? Or just in specific places.?

We can use if-else to filter specifically, that will work. So if you want to exclude a post somewhere based on the category, you can use that. But as a post may specify multiple categories you will probably need some array operations or a for-loop as well.

For example:

We have four different categories: A, B, C, D

On the homepage we see the blog posts from all 4 categories and it get listes according to the date. Right?

I want that from that list of blog posts on homepage, it should not show the blog posts of D category.

Can that be possible?

Yes, but you will have to modify the theme.

Somebody correct me if I am wrong, but I do not think that this is supported out of the box.

Are you using minima? (The default theme)?

I think you didn’t got my point. :confused:

Modifying a theme is not so difficult. But you do need some html/css and possibly programming experience.


you can use the snippet example that @rdyar provided just change out the operator
{% if post.category != "D" %}

1 Like