'jekyll: check if there are no posts

How can I check if there are no posts in the _posts folder?

So far, I've tried

{% if site.posts == null %}
  <p>No posts...yet.</p>
{% endif %}

and

{% if site.posts == nil %}
  <p>No posts...yet.</p>
{% endif %}

Is this possible in Liquid?



Solution 1:[1]

Here is a simpler approach.

{% if site.posts.size == 0 %}
  <p>No posts...yet.</p>
{% endif %}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Convincible