Goodbye Ghost

The Ghost blogging platform seemed like the best thing ever.. until I started trying to use it for slightly more advanced things like "Photo Galleries" and "Contact Forms".. then it became more annoying then anything else. And although I did find ways to workaround that.. it was REALLY slow.. I know I could host it myself somewhere.. but that's a hassle and costs a bit too.

So I stopped using it, https://kiwidev.co.nz languishes away un-loved or read.

Better to just make my own from scratch.

So I tried it..

DIY Blog

I started off trying to build an all in one app with NodeJS and MongoDB.. but again, I hit some interesting "cost vs performance" issues.

Using NodeJS is all good and hosting in Heroku is all good.. except I'd need to store my files on S3 as Heroku doesn't do persistence storage. That and to have a reliable site running it'd cost at least $7USD / Month for Heroku.

But OK, that's cheap.. but MongoDB is not so cheap for such a small APP. MongoLab has free MongoDB hosting, which is great; but there's no support or backups for it. Compose.io is great, but its $18USD / GB / Month. So we're already costing more than the $10USD / Month I'm paying to Ghost.

So.. I stopped that development.

Off the Shelf?

Then I thought, maybe a static site generator, like Jekyll.. but that's written in Ruby.. which I don't understand or like. Are there any written in JavaScript or even better Node.JS?

Yes, there's a bunch of them.. But. Big But.

Finding one that A: Works and B: Is maintained, proved pretty difficult. I tried Hexo, Harp and Yarn to name a few. Yarn seemed quite promising.. until it was broken out of the box and hadn't been updated in a few years.

So I dropped that idea too.

Lightbulb!

I had this thought "Why can't I build my own static site generator?", it can't be that hard after all.

So I did.

I designed and build this blog from scratch using as few npmJS modules as I could so hopefully I wouldn't get stuck with un-maintained code.

Hosted directly on Amazon's S3 Storage service and costing about $0.04 USD / Month to run and maintain.

I was going to go the route of using markdown files with Yaml at the top to track the Publish Date, Tags, Slug etc.. and the date and slug in the filename so I could track them offline.. but that would mean I need to backup those MD files somewhere.. and I tried it with S3 for awhile.. but it was too convoluted, esp once I thought I'd build a Web UI to create and edit posts.

So I wen't full-circle and combined both projects into one. Create a Web UI to create/edit posts, save them to MongoLab and backup MongoLab to S3 myself ($2USD per backup with MongoLab), then pull data form Mongo and build a static site and deploy it.

Easy. xD Wayyy easier than swapping S3 files in and out of memory.

Caveat

The only lil issue with this is.. Caching.

I need to find a way to make sure that whenever I re-publish the site, visitors get that latest version, not their cached version. Looking at the CacheControl Header which can be set by the aws-sdk on upload,not sure if that's enough yet.

I got the caching working great.

Setup ETag and CacheControl headers via the aws-adk. All resources cached correctly and anytime an update is published users get the latest version without resorting to CTRL + SHIFT + R. :)