Unable to find current post's category jekyll

792 views Asked by At

I want to display keywords and description automatically according to the category of the current post. I've used the following code, but it doesn't worked.

{% if page.categories = "category" %}

{% else %}

{% endif %}

But while using {% page.categories %} it is echoing out the category name correctly. Here are my two doubts:

  1. How can I compare the current post's category?
  2. Are {{ }} and {% %} are same here?
1

There are 1 answers

0
Hossain Mohd Faysal On BEST ANSWER
  1. It should look like the following:

    {% if page.categories == 'some-name' %}

    Hei I am in some-name category

    {% else %}

    No I am not in some-name category

    {% endif %}

2.

No, {{ }} and {% %} are not the same. {{ }} is used for echoing stuff, while {% %} is used for logic expressions and arguments.