Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用if语句向body标签添加一个类,如果页面是一篇文章,那么如果页面是一篇文章,则将页面添加到类中,然后向它添加文章。我不知道具体如何做到这一点,有人可以帮我弄清楚吗?
您可以测试page.dateor的存在page.id,例如
page.date
page.id
<div class="{% if page.id %} post {% else %} page {% endif %}"> ... </div>