Skip to content

Instantly share code, notes, and snippets.

@tlatsas
Created August 23, 2011 10:16
Show Gist options
  • Save tlatsas/1164797 to your computer and use it in GitHub Desktop.
Save tlatsas/1164797 to your computer and use it in GitHub Desktop.
jekyll post template generator
if [[ -z $1 ]]; then
echo "A post title is required. Bye.."
exit 1
fi
_post=$(echo $1 | tr ' ' '-')
_date=$(date +'%Y-%m-%d')
_datetime=$(date +'%Y-%m-%d %H:%M:%S')
_title="${_date}-${_post}.markdown"
_cwd=$(pwd)
_post_file="${_cwd}/${_title}"
if [[ -f ${_post_file} ]]; then
echo "File already exists. Bye.."
exit 1
fi
cat << EOF >| ${_post_file}
---
layout: post
title: $1
date: $_datetime
---
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment