Why a blog?

I wanted to create a blogging platform for a while. Throughout my career, I had always recommended to a number of people to create a blogging platform to share ideas, but I realised I never actually created one myself. In addition I wanted a platform to be able to document my many ongoing projects, which I never get round to finishing, due to a lack of accountability - something I hope this blog will help with!

How I went about it

The blog is simply a medium to capture thoughts, therefore I didn’t want to put that much time into setup and maintenance. Eventually I arrived on the following services in combination to create this website. This allows me to write my blog posts in markdown, and for them to be staticly compiled into HTML and served on the internet via a fast static sight CDN.

  • Hugo - Fast static site generator written in Go.
  • Netlify - Hosting for static site, with features such as automatic deployments
  • GitHub - Should be a given for hosting code
  • Namecheap - Domain name hosting

The Setup

A quick introduction on how to get a very similar blog setup:

1. Get a blog up and running with Hugo

Hugo requires the installation of an application on your local system, however where I can, I avoid installing application directly on my laptop. Instead I wrote a small bash command which I included in my .bashrc file, which launches a temporary docker container. This allows me to use the hugo command as normal in the command line, as if hugo was installed directly in my bin folder:

function hugo() {
    docker run \
        --rm -it \
        --name hugo_$(date +"%H%M%S") \
        -u $(id -u):$(id -g) \
        -v "$(pwd)":"$(pwd)" \
        -v "$(pwd)":"/src" \
        -p 1313:1313 \
        klakegg/hugo:0.95.0 \
        "$@"
}

Setup for Hugo was done by following the (very good) quick start guide

I also utilised the papermod theme. Following the Papermod installation guide was pretty straightforward, just install it as a submodule into you Hugo git repository and set the required config. Papermod is great, giving you post archive, search, day/night mod, among other nice features.

Key docs pages that helped me were

2. Store your content on GitHub / GitLab

Probably the most straightforward step. I chose GitHub has it’s the most common and now supports private repos for non-paying users.

Set up a private repo and follow the instructions presented to commit and push your Hugo directory there.

3. Host using Netlify

Netlify setup is also pretty straightforward too. Register an account and via their setup process link up your GitHub repository. You will need to add a netlify.toml file into your root directory, which indicates to Netlify how to build your code. I use the below, which I pulled from one of their example files.

[build]
publish = "public"

[context.production.environment]
  HUGO_VERSION = "0.95.0"
  HUGO_ENV = "production"

[context.deploy-preview.environment]
  HUGO_VERSION = "0.95.0"

That’s it. Commit and Push, and your blog will be live, on a Netlify subdomain. Next step is hooking up your own domain.

4. Get connected up to a domain

Finally register your domain, which I did via Namecheap. You will need to either use Netlify’s wizard, or configure your domain to point to Netlify manually. This will involve setting a A or ALIAS record, and a CNAME record for the www subdomain in your domain DNS setting. Pretty standard stuff and resources can be found in in the Netlify Docs.

Make sure your hugo config.toml file is updated to contain the baseURL

baseURL = "https://www.amishbhadeshia.co.uk"

Commit and Push, and then then depending on your DNS TTL, your site should be live (with HTTPS 😀) as quickly as within 10 minutes.


Conclusion

In my opinion the blog setup was a success! The total time everything took was around 3/4 hours, and everything works as smoothly as you can imagine. Posts are written in markdown and previewed locally. Once they are committed, the Netlify pipeline does the rest, and in 2 minutes the site is live. There are some minor tweaks to make here and there, but on the whole, I’m very happy with the process, and can now focus on writing posts.

Gotchas

I’m outlining below some common “gotchas” I encountered when I was setting up this solution:

ServiceProblemSolution
NamecheapNamecheap does not allow responding to an email address without buying a full smpt serviceI had to create an email forwarder for the alias hello@amishbhadeshia.co.uk to forward to my personal email. This means all responses at the moment will come from my personal email.
NetlifyNetlify does not automatically set up DNS setting on .co.uk LTDThis just need to be done manually by following the details on this link here