jekyll:检查是否没有帖子 [英] jekyll: check if there are no posts

查看:66
本文介绍了jekyll:检查是否没有帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查_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 %}

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

在Liquid中有可能吗?

Is this possible in Liquid?

推荐答案

获取posts数组的大小,然后将其与0进行比较:

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 %}

这篇关于jekyll:检查是否没有帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆