How to create drafts in Jekyll

Drafts in Jekyll are useful if you like to write posts in advance.

To create a draft in Jekyll, create a folder in the root called _drafts. You will keep your draft posts here.

The difference between the posts in this folder and in the regular _posts folder is

  1. The posts in the _drafts folder won't be published until you move the posts to the _posts folder. However, you can view the posts in the _drafts folder using the --drafts flag.

  2. The posts in the _drafts folder typically don't have the date in the file name. i.e instead of 2020-01-01-post-1.md, it would be post-1.md. You add the date after you move it to the _posts folder. I will show you how to work around this as well using the --future flag.

Viewing the posts in the _drafts folder

To view the posts in the _drafts folder, run the bundle exec jekyll serve --drafts command (or jekyll serve --drafts depending on which one works for you). This will allow you to view the drafts.

If you want to keep the dates in the filename of the drafts, then run bundle exec jekyll serve --drafts --future. More info on viewing Jekyll posts with a future date in this article. I actually do it this way because I like to have the filename with the dates so that I know when I want to publish the post.

My typical workflow is

  1. Create the post in the _drafts folder.

  2. Once I want to publish the post, I move the post in the _posts folder (if you don't have the date in the filename, remember to add it).

Make one page websites quickly using my Carrd Templates