سؤال

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. 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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top