Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can jekyll judge whether it is a page or a post?

I want to add a class to the body tag using if sentence, if the page is a post then add page to the class if the page is a post then add post to it. I don't know in specific how to do this, can anyone help me figure it out?

like image 978
Liang Avatar asked Dec 16 '12 16:12

Liang


1 Answers

You can test for the presence of page.date or page.id, e.g.

<div class="{% if page.id %} post {% else %} page {% endif %}">
   ...
</div>
like image 192
huon Avatar answered Oct 23 '22 06:10

huon