A New Post Script for Jekyll

The Main Thread is a static site generated with Jekyll. I love a lot of things about this setup, like being able to host it on S3, but there's too much friction when adding new posts. Today I finally got around to writing a small bash script for generating new posts. I had previously been using a TextExpander snippet to fill in the metadata but I still had to save the file in the write place with the right filename like an animal.

DATE=`date +%Y-%m-%d`
FILE=source/_posts/$DATE-$1.md
TITLE=$2

shift 2

cat > $FILE <<- EOM
---
layout: post
published: false
title: $TITLE
excerpt:
tags: $@
---
EOM

open $FILE

This dumps some pre-filled metadata into a new file and opens it with BBEdit (on this computer at least):

> cd path/to/project
> ./post.sh file-name-slug "Title of Post" as many tags as I want

"A New Post Script for Jekyll" was originally published on 23 Nov 2014.