Josh Branchaud has a cool python script called jekyll-post that lets you auto-generate the basics of a Jekyll blog post. This has two huge savings:

  1. The faster and easier it is to get started on a post, the more likely you’re going to write something, particularly if you only have a few minutes during a break.
  2. The semantics of how a Jekyll post is supposed to be created are precise. It’s easy to get them slightly off unless you either (a) memorize them or (b) get in the uncomfortable habit of copying and pasting them from a previous entry. The latter is really bad if you forget to change out one of the placeholder values from the copied entry. The whole thing just feels gross. Auto-generating the scaffolding guarantees this can’t happen.

Installing Josh’s python script is ambiguous if you’ve never actually done that sort of thing before. What you have to do is create a file named jekyll-post and put that in your bash folder. If you’re not sure where your bash folder is, here’s how you can find out. Once this file is in your bash folder and you’ve made sure permissions are correct on it, you can just type that filename in a Terminal window and it’ll execute that file, along with any arguments you give it.

I’ve made a couple of changes to Josh’s script, which you can see here. A quickdiff comparison with his master shows that:

  1. I think the title should be lowercased for the page URL. I don’t like capital letters in my URLS. They look cleaner without them.
  2. I want the default directory to be the _posts directory, not the current directory. 99% of the time, I want something in the _posts directory, so why make me specify that or have to cd into it?1
  3. I don’t want all that frontmatter. This is an opinionated change but I just don’t use those variables in Jekyll posts.

Assuming I’m in my Jekyll blog’s root directory, I can write this in terminal and it creates the proper file name in the proper folder with the proper frontmatter:

$ jekyll-post "Initializing Posts in Jekyll"

To really get a streamlined process it helps to have a few extra bash commands: one to cd to your blog root directory, one to start Jekyll, and one to open your IDE. The first two look like this:

alias blog='cd /path/to/blog/directory'
alias jekyll-start='sudo bundle exec jekyll serve'

Assuming you’re using VSCode, the third one is simply code . (notice the dot). The workflow from any Terminal window now becomes:

$ blog
$ jekyll-post "Initializing Posts in Jekyll"
$ jekyll-start
$ # switch to a new tab, which you'll use for git, and then:
$ code .

This takes roughly the time to initialize a WordPress draft. It feels roughly a thousand times better.

  1. The only other place you’d really want to put stuff is in the _drafts folder but I actually don’t like this folder. If you don’t want to publish a post, consider putting it in your _posts folder and not pushing the change to GitHub. Or give it a future date, push it, and Jekyll will be smart enough to refrain from showing it until the proper time. Either of these options seems more intuitive than having to move a file from one folder to another. Maybe that’s just me. ↩︎