Skip to content

Instantly share code, notes, and snippets.

@rtablada
Forked from scooooooooby/new-post.sh
Last active October 26, 2015 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtablada/37ed13e62f283c347f37 to your computer and use it in GitHub Desktop.
Save rtablada/37ed13e62f283c347f37 to your computer and use it in GitHub Desktop.
Create Jekyll posts with their YAML matter quickly from the command line.
jekyll-post () {
#!/bin/bash
echo "Title of post:"
read title
echo "Description of post:"
read description
echo "Tag post:"
read tags
dateStr=$(date +%Y'-'%m'-'%d'-') # Current date
blogFolder=~/boondoggles/thoughts/_posts # _posts folder of Jekyll blog
YAML=$'---
layout: post
title: '$title'
description: '$description'
tags: ['$tags']
---' # YAML matter at top of blog post
lowercase=$(echo "$title" | tr '[:upper:]' '[:lower:]')
formattedTitle=${lowercase// /-}
echo $formattedTitle
newFile=$dateStr$formattedTitle'.md'
echo "$YAML" > $blogFolder/$newFile # Create post in correct folder
vim $blogFolder/$newFile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment