Create a gist now

Instantly share code, notes, and snippets.

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).

@pborreli

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

@benbalter
Owner

@pborrell Great idea. Updated. Thanks.

@vitoleandro

Updated !

@TheFox
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.

@theJollySin

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?

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