Easy Jekyll post drafting

Jekyll, the static site compiler powering this blog, comes with a nice draft feature for some time now. Draft posts are placed into the _drafts directory instead of the normal _posts directory and built and served only if a special flag is passed to Jekyll. After using this for some time now, it became a real chore to name and rename the files according to the proper Jekyll conventions (e.g. _posts/ Of course, I had to do something about it …

Using this tiny script, I can now create regular posts or drafts with the YAML header simply by writing

$ jk post A post about this
$ jk draft A draft about that

Furthermore, I can move posts between both directories, identifying the file in question via a simple fuzzy search1, e.g.

$ jk switch about that
Moved _drafts/ -> _posts/

moves the post to the drafts directory. The same mechanics is used to edit a file, e.g. Vim is launched for the draft if, I run

$ jk edit about that

That’s it.

  1. The implementation is questionable but it works fine for me.


Post a comment

Name required

E-mail required, not published

Website optional

Comment Markdown accepted