Post without title in Jekyll

jekyll, ruby

Solution

You don't need to alter the jekyll codebase to remove titles. That can be done using different layouts with appropriate liquid filters and tags.

For individual post pages, simply make a new layout file (e.g. "_layouts/no-title-post.html") that doesn't have the `{{ page.title }}` liquid tag. In your _posts source file, set the YAML front matter to call it. For example:

---
layout: no-title-post
---

Note here that "title:" isn't required in the YAML front matter. If jekyll needs it, the value will be automatically crated from the filename. For example, "_posts/2012-04-29-a-new-post.md" would have its title variable set to "A New Post" automatically. If your templates don't call the title tags, it won't matter. You could include a "title:" in the front matter and it simply wouldn't be displayed.

You can also display the page without the title in your listing/index pages. Check the posts layout to determine if the title should be displayed. For example, to show titles on all your pages except ones that have the 'no-title-post' layout, you would do something like this:

{% for post in paginator.posts %}
    {% if post.layout != 'no-title-post' %}
    <h1><a href="{{ post.url }}">{{ post.title }}</a></h1>
    {% endif %}

    <div class="postContent">
    {{ post.content }}
    </div>
{% endfor %}

In that case, the link to the page itself is also removed. If the page needs to be addressable, you would have to add the link back in somewhere else.

Problem

In my Jekyll blog, I would like some posts not to have a title. How could I modify the Jekyll codebase to make it so that posts do not require a title?

Original source