blog archive     the meetup     about     contact me

my blogging workflow

I really enjoy using Github Pages and Jekyll for my blogging platform. Using markdown, git, and terminal for creating/posting web content seems so much more authentically me than using a WYSIWYG editor.

Here I’d like to document/share my process:

Typically I have a local directory, 5280dev, where I do all of my edits.

1) Before starting a new post, I first do a git pull to ensure my local repo is current. Then I execute a simple bash script that builds out a markdown file in a staging directory:

cd 5280dev/5280sec.github.io

git pull https://github.com/5280sec/5280sec.github.io.git

./newpost.sh

newpost.sh:

#!/bin/bash
read -r -p "Enter the title of your post: " RAW
TITLE=$(sed "s/ /-/g" <<< "$RAW")
POSTSPATH=$(pwd)"/staging/"
DATE=$(date +'%Y-%m-%d')
NEWFILE=$POSTSPATH$DATE"-"$TITLE".md"

echo "---
layout: post
title: $RAW
comments: true
---

2) After I’ve completed my new post (I typically write my markdown in atom), I move it from staging:

mv staging/2017-01-01-whatever.md _posts/

3) And now I can test it locally at http://localhost:4000 using a Jekyll Docker container before I push to Github. This one-liner will spin up a new Jekyll container, mapping the volume to my repo:

sudo docker run --rm -it -p 4000:4000 -v $(pwd)/:/srv/jekyll jekyll/jekyll:latest jekyll serve --watch --incremental

4) Once I’m happy with my edits, I commit 5280dev to Github:

git add {whatever}

git commit -m {message}

git push https://5280sec@github.com/5280sec/5280sec.github.io.git