Skip to content

Instantly share code, notes, and snippets.

Last active March 12, 2024 07:39
Show Gist options
  • Save benbalter/5555992 to your computer and use it in GitHub Desktop.
Save benbalter/5555992 to your computer and use it in GitHub Desktop.
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).

Copy link

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?

Copy link

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

Copy link

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.

Copy link

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

Copy link

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

Hi all, does anyone know whether it is actually possible to view a draft with a date in the filename?

The reason I'm asking this is because I use a script that takes the filename of my blog post (YYYY-MM-DD-post-name) to create a folder where I store my images, adding the date keeps the files neatly organised.

My scripts are based on taking the filename, which works if I write my drafts in the _posts folder but my jekyll blog doesn't seem to be able to find my drafts if I add date.


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