Multiple Drafts In Jekyll

November 6, 2022 0 Comments

Although it is only a static website, we can also use a Plugin in Jekyll. Let’s continue our discussion about creating drafts from the previous post. As you can see in the previous post, we created the drafts and first placed them in a special folder called _drafts. Then, when we are ready to publish it, we move it to the _posts folder with the correct name format.

Sounds easy, right? this shouldn’t be a problem if you only manage 1 or 2 post drafts. However, if you have 5-10 drafts of messages, it can be difficult to change each file name and specify the correct date by hand. Let’s see how to simplify the workflow with a Jekyll Plugin.

First Steps
Before continuing, we will create a new folder called _plugins; this folder is necessary because Jekyll searches for and executes Plugins from the folder. We also need to create a new file called publisher.rb in it; technically, you can freely name this file with any name.

We are going to use a Jekyll Plugin created by Jeffrey Campbells. This plugin takes care of the hassle of publishing a message from a draft in Jekyll. The file is correctly renamed with the date. And the date is also indicated in the Post Front Matter section.

The following is the source code of the plugin available on this main page. Copy this Code below and paste it into The editor.rb file that we have just created.

If your Jekyll server is running, restart it for the Plugin to work.

Using the plugin

To use the Plugin, we need to create a new folder named _publish. We will move our draft messages to this folder as soon as we are ready to publish them. However, before that, set the date to unpublished in the title topic of the draft publication. Now move the draft to the _publish folder.

As mentioned earlier, Jekyll automatically moves the folder to _posts, sets the publication date, and then publishes the message for you.

Last Thought

We have seen that Jekyll is extensible with a Plugin. In this article, for example, we used one to simplify the process of publishing a draft. You will find other Jekyll Plugins on this page: Available Plugins. Now we have learned how to set up Jekyll and publish a post-draft. In the next article, we will show you how to publish Jekyll Blog via FTP on an online server.

Leave a Reply

Your email address will not be published. Required fields are marked *