Instantly share code, notes, and snippets.

What would you like to do?
Example of using drafts in Jekyll

Let's say your Jekyll site's directory structure looks like:

|-- _config.yml
|-- _drafts/
|   |--
|-- _layouts/
|   |-- default.html
|-- _posts/
|   |-- 2013-05-10-a-published-post
|-- index.html

How to preview a draft post

Normally (and on GitHub Pages) Jekyll will ignore the posts in the _drafts folder, publishing only the posts in the _posts folder. If you run Jekyll locally with the --drafts flag (e.g., jekyll serve --drafts), Jekyll will include any posts in the _drafts folder, just as if they were published post (but don't worry, only locally).


This comment has been minimized.

pborreli commented May 10, 2013

i would add a / after the folders name to mark the difference between a folder and a file


This comment has been minimized.


benbalter commented May 12, 2013

@pborrell Great idea. Updated. Thanks.


This comment has been minimized.

vitoleandro commented May 13, 2013

Updated !


This comment has been minimized.

TheFox commented Sep 17, 2014

Is there a variable to check if a post is a draft or not? Something like post.draft but without using draft: true in each file.


This comment has been minimized.

theJollySin commented Jan 9, 2017

Now that GitHub Pages are limited to 10 builds per day, is it safe for me to assume that committing to the _drafts folder does not trigger a build?


This comment has been minimized.

magicznyleszek commented Mar 25, 2017


It's not 10/day it's 10/h, as you can read at

GitHub Pages sites have a soft limit of 10 builds per hour.

And as for _drafts triggering a build, it doesn't really matter. Every commit to selected branch triggers a build


This comment has been minimized.

RoyiAvital commented Oct 2, 2017

The documentation says Drafts are posts without a date..

What does it mean?
Does it means I should remove the date field from the page:

title: 'Something Boring'
date: 2017-11-30
author: Someone
layout: post
class: news

Thank You.


This comment has been minimized.

Mark-RSK commented Feb 23, 2018

@RoyiAvital The draft post will not appear in the site folder if it contains a date property and you are running with the --drafts switch. Remove the date property and it will output for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment