我有一个FOR语句,输出 jobs
类型的所有帖子 .
{% for post in site.categories.jobs %}
<article>
<h3><a href="{{ post.permalink }}">{{ post.title }}</a></h3>
<p>{{ post.summary }}</p>
</article>
{% endfor %}
但如果 jobs
中没有已发布的帖子,我想显示"We're not hiring right now"消息 .
你能创建一个IF / ELSE语句来检查特定类别的帖子吗?
1 回答
尝试使用
{% if site.categories.jobs == null %}
进行检查 .