Successive Approximations

Running a Ghost Blog, Part 1

Running a Ghost Blog, Part 1

Depending on how you count it, this is the fifth or sixth blog I've contributed to, and the first running on Ghost. The first was on Blogger (I never did have a LiveJournal), and the rest of them have been WordPress, which has been the reigning champ of the blogging world for a long, long time.

But WordPress is... old. It uses PHP and CGI scripts, which are perfectly functional but dated. Nobody with a choice would use those technologies to start something new and modern.

Practically speaking, this isn't a problem. As a rule, old tools are debugged and they've had a lot of time to have the kinks worked out. There is an incredible amount of support around WordPress. There are people who make a living just making WordPress websites for other people who just need to actually run their business.

But my profession is writing software, so there's just something unpleasant about tinkering with a functional but clunky antique. This blog is just a hobby, and I fully intend to have fun with maintaining it. You wouldn't expect a gearhead to want to spend his weekends wrenching on a 2008 Ford Taurus. Sometimes it's more interesting and satisfying to work on a project that has some quirks, because it gives you challenges to overcome.

Technical Challenges

So, to get the blog looking this way, the main hurdle I had to overcome was the fact that there is no way to edit the theme for the blog directly. You can upload a new one as a zip file, but otherwise you're out of luck on customization.

But I am running this blog on a Linux virtual machine in the cloud, and Ghost is just a node.js daemon running a particular set of software. And it just so happens that the theme isn't stored in the MySQL database, it's just unzipped and stored on the disk.

So, thanks to the Unix Philosophy ("Make each program do one thing well."), I was able to build my own system for editing the themes quite efficiently, and having a good time doing it.

The first challenge was to edit the files locally and send the changes to the linux server. So I used scp to copy the files locally. I would make the changes, and then let rsync figure out which files have changed and only upload those to the server. So that command comes out looking like

rsync -r -e ssh ./* <vm_ip_address>:/var/www/ghost/content/themes/theme-directory

The second challenge is that the website template actually uses gulp, which generates the minified files that browsers can read based on source files that can be read by humans. To run gulp, I first have to run npm install, which means we have to make sure not to rsync the node_modules directory (generated by npm install) up to the server. So I had to add a flag to the rsync command.

rsync -r -e ssh --exclude=node_modules/* ./* <vm_ip_address>:/var/www/ghost/content/themes/theme-directory

The third challenge is that I for some of these changes to show up on the server, I have to restart the daemon running the blog. This is easy enough to do (ssh <vm_ip_address> "cd /var/www/ghost/ && sudo -u ghost-mgr ghost restart") but pairing it with the gulp compile and rsync means it's time to write a Makefile.

The beauty of make is its simplicity. While it has some useful advanced features, at the end of the day it's just a way to string together one-liner scripts into batches that need to be run simultaneously. And so I write a Makefile, and after each edit to my files, I just run make gulp upload and 10 seconds later the changes are deployed. Here's what the Makefile looks like:


	rsync -r -e ssh --exclude=node_modules/* ./* <vm_ip_address>:/var/www/ghost/content/themes/theme-directory
	ssh <vm_ip_address> "cd /var/www/ghost/ && sudo -u ghost-mgr ghost restart"

And then the cherry on top is creating a git repo to track all the changes I make to the source files.

So, I clearly can't recommend this to a non-technical user. But for someone like me, looking for a hot rod to work on in my spare time that also gives me a slick, fast blogging engine, Ghost is exactly it.

As time goes on, we'll see how it holds up. But for now it does what I need and it's fun to play with.

Ben Berry

I don't have comments on my posts, but if you want to reach me, email me at my first name at