newpost-jekyll

Automating dumb stuff lately. Here’s my code for a new jekyll post.

#set $now to date format used by Jekyll
now=$(date +"%Y-%m-%d")    #get user input for $post_name
echo "enter post name"
read post_name
#create file using name and date in Jekyll format
touch $now-$post_name.markdown
#create YAML font matter block
echo -e "---\ntitle: $post_name\nlayout: post\ndate: $now\n---">> $now-$post_name.markdown
#some optional templating -- add to as needed
echo -e "### Header size 3" >> $now-$post_name.markdown
echo -e "[content_linkname](url "Title")">> $now-$post_name.markdown
# open to line of file after the font matter
vi +6 $now-$post_name.markdown # amend if font matter line numbers change or become variable
comments powered by Disqus