简体   繁体   中英

How does the loops and variables in Jekyll?

When I compare in if the post.category is as if there was a post that is the variable is more when I put {{post.category}} it prints the name. It's like if he did not exist in most if I put in if site.post.category handle all values. The problem is that I want to get the current post to compare if that category. I want to list the 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>

尝试使用类别

{% if post.categories | contains: 'Eventos' %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM