Exclude the particular categories


#1

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


#2

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

http://jekyllsnippets.com/excluding-posts-by-category/


#3

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.


#4

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?


#5

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)?


#6

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


#7

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


#8

@yashumittal

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