jekyll: 检查是否没有帖子

dup*_*ic8 4 liquid jekyll

如何检查_posts文件夹中是否没有帖子?

到目前为止,我已经尝试过

{% if site.posts == null %}
  <p>No posts...yet.</p>
{% endif %}
Run Code Online (Sandbox Code Playgroud)

{% if site.posts == nil %}
  <p>No posts...yet.</p>
{% endif %}
Run Code Online (Sandbox Code Playgroud)

这在液体中可能吗?

mar*_*nuy 5

Grab the size of the posts array and then compare that to 0:

{% assign psize = site.posts | size %}
{% if psize == 0 %} 
  <p>No posts...yet.</p>
{% endif %}
Run Code Online (Sandbox Code Playgroud)