How do loops and variables work in jekyll?

0

When I compare in if if post.category is as if there was no post variable that is no longer when I put {{post.category}} it prints the name. It's as if in if it does not exist anymore if I put site.post.category in if it takes all values.

The problem is that I want to get the current post to compare if it's that category. I want to list posts by category.

<div class="posts">
  {% for post in site.posts %} 
    {% if post.category == Eventos %}
      <hr />
      <div class="post">
        <h1 class="post-title">
          <a href="{{ site.url }}{{post.url}}">
            {{ post.title }} 
          </a>
        </h1>
        <span class="post-date">{{ post.date | date_to_string }} / {{ post.category }}</span>
        {{ post.excerpt }}
        <h6><a href="{{ site.url }}{{post.url}}">Leia mais...</a></h6>
      </div>
    {% endif %}
  {% endfor %}
</div>
    
asked by anonymous 24.02.2015 / 15:24

1 answer

1

The syntax of the loop is correct, set if to:

{% if post.category == "Eventos" %}
    
24.02.2015 / 17:55