I believe I’ve just about nailed down my perfect blogging setup using Jekyll, Git, and Working Copy. I’ve got darn near everything I wanted out of WordPress and its defective iOS app, and then some. I’ll briefly describe my setup.
My personal web space is on the SDF MetaArray. I’ve got a Git repository housed within my home folder, called
~/git/blog.git. My web files are served out of
~/html/ and I have the Git repo cloned into
~/html.jk/. A symlink connects
~/html.jk/_site to grab the files output by
I have put a post-receive hook in
~/git/blog.git/hooks/post-receive and made it executable:
#/usr/pkg/bin/bash PWD=`pwd` WORK_DIR=/meta/s/scrow/html.jk unset GIT_DIR echo "Checking out" (cd $WORK_DIR && git pull -f) (cd $WORK_DIR && git checkout -f) echo "Submodule update" (cd $WORK_DIR && git submodule update --init --recursive) cd $WORK_DIR /meta/s/scrow/local/bin/jekyll build cd $PWD
Note that the submodule updates aren’t really necessary here. I reused this hook from some other web sites I maintain and decided to just leave it there in case it ever becomes relevant.
What this hook does is pulls down the latest copy of the
master branch and kicks off a
jekyll build which produces the static site files in the
A separate script called
~/local/bin/update-blog.sh is run by a cron job once per minute for purposes of processing scheduled (future-dated) posts:
#!/usr/pkg/bin/bash PWD=`pwd` cd /meta/s/scrow/html.jk /meta/s/scrow/local/bin/jekyll build cd $PWD
And the corresponding crontab entry:
* * * * * sleep 5s; /meta/s/scrow/local/bin/update-blog.sh > /dev/null 2>&1
The 5-second pause is to ensure Jekyll helps ensure posts are published during the correct minute.
I’m hoping to primarily do most of my blogging either from my iPad or from my Raspberry Pi, both of which have been carefully set up to do as much work offline as possible. By “offline” I mean without continuous Internet access, but occasional, intermittent ability to transmit and receive information.
Turns out Jekyll and Git are perfect for this.
With my blog repo cloned to my iPad Pro using Working Copy, I am able to compose new articles or make edits to existing content and commit to to the local repo within the app. It sounds like some folks are using other text editors such as Textastic or Editorial for this, but I find the built-in editor in Working Copy is plenty adequate for this purpose.
When I can get to Internet access, I simply need to push my changes up to the repo. If I’ve made changes or created new articles elsewhere, that all works itself out through the normal Git conflict resolution process. Generally speaking, this is just a merge of whatever’s in each remote repo.
Git handles small binary attachments like images just fine, too.
All of this can be done from the Raspberry Pi, as well. I’ll sync up to the main repo as connectivity is available, and in the meantime can basically queue up content updates until I am able to push up to the repo, just as I would on the iPad.
This may come in handy real soon, since I’m expecting to be connectivity-challenged next week.
The next phase of my conversion to Jekyll is going to be getting a commenting system going. Until that’s up, you can feel free to send me an e-mail with any comments or suggestions.