Skip to content

Instantly share code, notes, and snippets.

@febs
Forked from mviitanen/create-jekyll-post.sh
Created December 8, 2015 22:53
Show Gist options
  • Save febs/674dca97b0d045038ca4 to your computer and use it in GitHub Desktop.
Save febs/674dca97b0d045038ca4 to your computer and use it in GitHub Desktop.
A shell script to create a new jekyll post. Maybe there is an easier way, but this script generates a basic markdown post for jekyll. It has head matter, samples of some common formatting, and a link to a more complete documentation of the format.
#!/bin/bash
if [ "$#" -ne 1 ] ; then
echo "Usage: $0 <title>" >&2
exit 1
fi
title=`echo "$1" |sed 's/ /-/g'`
fileName="_posts/`date +%Y-%m-%d-$title.markdown`"
touch $fileName
cat > $fileName <<DELIM
---
layout: post
title: "$1"
date: `date "+%Y-%m-%d %H:%M:%S"`
categories:
---
[Basic syntax help for Markdown](http://daringfireball.net/projects/markdown/basics)
A First Level Header
====================
A Second Level Header
---------------------
Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.
Some of these words *are emphasized*.
Some of these words _are emphasized also_.
Use two asterisks for **strong emphasis**.
Or, if you prefer, __use two underscores instead__.
### Header 3
> This is a blockquote.
>
> This is the second paragraph in the blockquote.
>
> ## This is an H2 in a blockquote
* Dandy.
* Gum.
1. Red
2. Green
3. Blue
This is an [example link](http://example.com/).
[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[3]: http://search.msn.com/ "MSN Search"
To highlight:
{% highlight text linenos %}
some text to be syntax highlighted....
{% endhighlight %}
![alt text](/path/to/img.jpg "Title")
DELIM
vim $fileName +9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment