cdrrazan
cdrrazan

Reputation: 138

Cannot load multiple commenting system in Jekyll blog

I am trying to implement disqus and facebook commenting system for different categories in jekyll blog.

Here is my current approach.

     
  {% for category in site.categories %}

  {% if category.type == "personal" %}

  {% include facebook.html %}

  {% else %}

  {% include disqus.html %}

  {% endif %}

  {% endfor %}

Expected result: Facebook comment should be loaded in category personal from facebook.html otherwise disqus comment should be loaded in all other category.

Actual result: Disqus comments loads automatically in personal category regardless of the loop.

What should be changed to make the comments load correctly?

Upvotes: 0

Views: 58

Answers (2)

marcanuy
marcanuy

Reputation: 23972

Category doesn't have a type attribute. Checking directly like:

  {% for category in page.categories %}

  {% if category == "personal" %}

  {% include facebook.html %}

  {% else %}

  {% include disqus.html %}

  {% endif %}

  {% endfor %}

Should detect the personal category and load disqus comments.

Upvotes: 0

David Jacquel
David Jacquel

Reputation: 52819

It seems that you want to print disqus or facebook on each page depending on "personnal" category presence.

As @marcanuy says, you have to refer to page.categories, which is an array.

{% if page.categories contains "personnal" %}
  {% include facebook.html %}
{% else %}
  {% include disqus.html %}
{% endif %}

Upvotes: 2

Related Questions