Skip to content

Instantly share code, notes, and snippets.



Last active Dec 1, 2017
What would you like to do?
Publish Jekyll posts using simple git workflow
set -euo pipefail
# Move jekyll draft to post, timestamp it, and start to commit it
# Useage:
# $ ./ _draft/cool-article.markdown
# moves the draft to _posts/2017-12-01-cool-article.markdown
# inserts the published date into the "front matter"
# adds the changes and prompts you to commit them
shortname=$(basename -s .markdown $original)
newfile="_posts/$(date -I)-${shortname}.markdown";
sed -i "2 i date: $(date '+%F %T %z')" $original
git mv "$original" "$newfile"
git add $newfile
git commit -e -m "publish $shortname"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment