How do you host your blog?

Introduction

Ask 100 developers to build a todo list and you will see 101 different ways of doing it. Same thing for blog hosting – everyone does it in their own way. I also moved it recently so this is an apt time to write this.

Pre-reqs

The blog is using a static site generator hexo. I write the posts in markdown and have a style theme [cactus dark] configured in a config.yml. hexo generate walks through all the .md files and generates a bunch of static files that can be served.

v1.0.0

The first setup was hosting it on gitlab pages and using their domain. The link was https://asad-awadia.gitlab.io/blog . Blog was the repo name. Enable pages in the repo setting and put the files in a public folder and gitlab takes care of the rest. The link just redirects to the new domain now.

New posts would take sometime to appear on the live site.

It was having issues the one time gitlab was having issues because cloudflare was having issues :p

v2.0.0

I wanted to move the blog to my own domain name. So I purchased the domain name aawadia.dev from gandi.net. Registered it in cloudflare for DNS management.

Rented a $5 droplet from digital ocean and put the static files in a folder [used git pull to get the latest files] and set nginx to serve files from that folder in front. Then added an A record for my domain in cloduflare pointing to the public ip of the droplet.

Cloudflare provided the cert and keys to be used with nginx for ssl. All requests to port 80 would get redirected to 443. Http2 server was also enabled on nginx. The folder that nginx was set to serve from was mounted in tmpfs [ram] to keep things snappy.

There would be massive network scanning by bots on the droplet - so it is important you keep your droplet secure. I had all requests to nginx that were not from cloudlfare blocked and only kept the needed ports open.

This served me well and the droplet never once gave any reliability issues.

v3.0.0

A few days ago I moved it from the server to netlify’s free plan. Netlify is like heroku for frontend. They already have templates for many different stacks. Set one up for hexo, gave the directory to serve from and the build command and netflify takes care of the rest.

Cloudflare dns console has a CNAME record pointing to the netlify internal generated project name. Cloudflare provides the cert and keys that are set up in netlify with the domain for https.

Now whenever I push a new post to gitlab - netlify starts a new build and pushes the updated version of the site.

Got CD for my blog lol.

Netlify gives 100GB of outgoing bandwidth on their free plan with overages being 100GB for $20 where as digital ocean’s smallest droplet gives 1TB of bandwidth with overage being $0.01/GiB.

Future

I want to add search, comment, and email subscription features to this thing eventually. Not sure what the low maintenance way would be. Will have to do some reading.