Create a gist now

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/
|   |-- a-draft-post.md
|-- _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).

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

Owner

benbalter commented May 12, 2013

@pborrell Great idea. Updated. Thanks.

Updated !

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.

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?

smutnyleszek commented Mar 25, 2017 edited

@theJollySin

It's not 10/day it's 10/h, as you can read at https://help.github.com/articles/what-is-github-pages/:

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 http://stackoverflow.com/questions/24098792/how-to-force-github-pages-build

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