In a Jekyll layout, is there any way to detect if the page is a normal page or a post? I want to display post titles, but not page titles. Like this:
{% if page.is_post? %}
<h2>{{ page.title }}</h2>
{% endif %}
{{ content }}
Since Jekyll 2.0, you can use Front Matter Defaults:
defaults:
-
scope:
path: "" # empty string for all files
type: posts # limit to posts
values:
is_post: true # automatically set is_post=true for all posts
then you can use {{ page.is_post }}
to check whether the page is post.
No idea why Jekyll doesn't set page.type
by default.