Skip to content

Instantly share code, notes, and snippets.

@chestone
Last active August 29, 2015 13:57
Show Gist options
  • Save chestone/9398279 to your computer and use it in GitHub Desktop.
Save chestone/9398279 to your computer and use it in GitHub Desktop.
Create a Jekyll post with front-matter
#!/bin/sh
echo "What would you like the title of your post to be?"
read post_name
echo "What categories would you like this post to be under?(space seperated list)"
read categories
today=$( date "+%Y-%m-%d" )
rawpost="$today-$post_name.md"
post=${rawpost// /-}
echo "Your post name is $post"
if [ ! -f "$post" ]
then
touch $post
else
echo "Post with the name $title has already been created. Please try another name." 1>&2
exit 1
fi
cat <<EOF >> $post
---
layout: post
title: "$post_name"
categories: $categories
---
EOF
echo "Post: $title created."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment