I have recently dusted off my old blog (with zero posts) in an attempt to start blogging again. I host a handful of sites and small web apps on a couple of 'micro' AWS Elastic Compute Cloud (EC2) instances.
Ghost is an amazing blogging tool, that gives a really nice experience for both reader and writer, without all the overhead of managing databases or complex CMS (Content Management System) set up. However, I'd previously found that running a node server to serve a production blog created a few problems including:
- security for editing/adding blog posts
- user permissions and managing storage of images
- node issues when using it as a live web server (crashing, poor CPU and memory usage when compared to Apache as a web server)
To overcome these issues, and because a simple blog is (or should be) just a simple set of static pages, I decided to use Ghost to structure and edit my blog posts and then publish these as static HTML (with CSS, JS and assets) pages to blog.jackspargo.com. Effectively, this means I run a local node server to build, edit, write and publish my blog posts, before generating the static pages using Buster.
Note that for the Ghost installation, you only need to follow the 'local / dev' steps as we'll not be turning this into a production Ghost server.
Prerequisites for this are:
- node (v6.5.0 - it seems that later versions aren't yet supported) - you may need to use nvm (node version manager) in order to be able to run older or newer versions of node for other projects
- Python and pip (Python package manager) - Python should be pre-installed on Macs and Linux machines, but pip may not be.
- wget - this will be installed on Linux machines by default, but not Macs. Use
brew install wgetto install wget.
First we need to install the Ghost CLI tools using npm - if using nvm make sure that you're chosen v6.5.0 or earlier before running this:
npm install -g ghost-cli
Once completed, create or cd into an empty directory where you want your blog to live and run:
ghost install local
This will take care of all the installation steps and, if successful, start your Ghost blog and server locally. You'll then be able to browser around, read, edit, delete and create new posts at http://localhost:2368.
Be sure to take a look at the settings (located at http://localhost:2368/ghost) to set your name, blog information and other data about your blog posts.
Now that we have our blog running locally, we need a way to capture the static pages and assets. This is where Buster comes in. It effectively runs through all the pages it can find at your locally running Ghost blog, and saves the pages as static HTML. It also updates links to CSS and JS assets, as well as to linked pages within your blog.
To setup Buster, you'll need need to run:
pip install buster
This will install Buster and add the command
buster to your path. Now run:
this will prompt you for a URL. For the purposes of what I've done, and what this blog post is describing, you don't need to enter anything here so just press enter.
buster generate --domain=https://blog.jackspargo.com
and Buster will output your entire static blog site to a folder called
/static. You can now put this folder on your web server via scp, git or just using your hosting providers upload facilities.
It's worth noting that Buster does some more clever stuff that I've not used here. If we'd wanted to deploy this to Github pages, this can be done using
For me, I've just checked this static folder into the git repository for my blog (along with all the local files and folders for development) and I use a Jenkins job to just copy the contents of
static to Apache's folder that serves traffic to blog.jackspargo.com. Let me know if a guide to this setup (including HTTPS certificates) would be useful and I'll write a post about it!
Thanks for reading - let me know if you've found this useful or have any comments. I'm @jackspargo on Twitter.