Instantly share code, notes, and snippets.

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

@pborreli

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

@benbalter

This comment has been minimized.

Owner

benbalter commented May 12, 2013

@pborrell Great idea. Updated. Thanks.

@vitoleandro

This comment has been minimized.

vitoleandro commented May 13, 2013

Updated !

@TheFox

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.

@theJollySin

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?

@magicznyleszek

This comment has been minimized.

magicznyleszek commented Mar 25, 2017

@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

@RoyiAvital

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.

@Mark-RSK

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