Posts /

Hide posts in Jekyll blog

16 Jul 2016

Hide unwanted post like drafts and samples from the blog

Not all posts that we write are ready to be published. Jekyll themes also contain some sample posts which may have important info about the theme. These drafts and sample posts must not be a part of the published website.

Jekyll provides us with two very simple ways to do so.

Method 1: Drafts

Drafts are posts on which you are still working on and which are not ready to be published yet. Drafts are located in /_drafts directory. Drafts are not published when the site is built. To build the website with drafts simply run jekyll serve or jekyll build with --drafts.

    .../_drafts/
        -your-draft-post.md

Drafts can be with or without a date. The value of last modification of the post will be used as date of the draft if the date is not mentioned.

Method 2: Future Posts

Future posts are posts on which supposed to be published in the future. Posts with date greater than the current date are not published by Jekyll. Future posts are created in the _posts directory, the only difference between a normal post and a future post is the date. To build the website with future posts simply run jekyll serve or jekyll build with --future.