Switching to Hugo Blog

Update :- This deployment in not in use anymore. check new setup here

For quite a while, I was planning to restart my blog to share my recent adventures and learnings in tech/life but the headache of maintenance and monthly bill to keep running it, leads to keep procrastinating it.

Why not Wordpress ?

I once started using blogspot during my college days and it was amazing but it didn't work for too long. Although the hosting, custom domain and other things were sorted, the efforts to customize little things annoyed me. Then after some friends recommendations, switched it to popular Wordpress but high server cost,time for maintenance and security issues forced me to look for alternatives.

A lot of non-programmers, tech-savvy people are using Wordpress and it is really easy to maintain, just install plugin for almost everything you want to do with Wordpress then why it is a maintenance overhead ?

Every other week I could see some bot scanning the very known Wordpress architecture to figure out loopholes and take it down and I don't want my Wordpress server sending backdoor data or displaying porn ads on my blog. All I needed was simple static blog with the comments on. Medium would have worked fine but I wanted more control on the content.


While reading some post in Go community I came to know Hugo, a static site generator. The idea of converting the .md docs to blog was really exciting. Those Markdown docs I keep creating during day to day base programming sessions, could be converted to blog post real quick.

After browsing through docs, It appeared very simple, powerful and really fast. I heard @spf13(Creator of Hugo) mentioning in talk that someone using Hugo to generate 25k static blog posts and it is still fast.


I have installed it on my favorite cloud AWS by simple following steps on this post. Once this you setup this way there is no need to put the content on server, it just directly serves from s3 using Cloudfront and Route53.

This setup is very cheap and if you are running on AWS free tier then almost free.


Didn't you just said it is dead simple then why you need to customize it ?

Hugo comes with it's own command line tools to generate, test and deploy the blog, once you put it with s3 it requires some additional scripts to handle seamless deployment so why not just write some script and bind it to tools you use everyday. I decided to combine it with npm by just adding some custom scripts.

Integration with npm

Hugo has it's own commands to run and build. In this simple config file, I have created small small scripts to handle these commands on Hugo level.

AWS CLI Integration makes these scripts more powerful to handle build and deployments.

Run Local

npm start command is linked to run Hugo server with all the drafts on local machine. Whenever you make any changes to files it reloads the blog in browser.


During the build, I don't want to reset my git logs as I am maintaining a state of blog on Github, So instead of deleting the whole public folder, only content will be removed not the .git files


In case of s3 Hugo setup, deployment require these things

  • Sync the local updated files with s3 bucket
  • Invalidate the Cloudfront cache to serve the fresh posts from s3 bucket

Check Deploy Status

Invalidation some times takes a while so how do I know if the cache is clear and the blog serving the updated posts ?

There might be some better way to solve this problem but I came with a simple script that checks the aws cloufront status from aws-cli and you can check the status of the latest deployment.

So you only need few npm commands to publish a blog post.

#run the local server
npm start

# create a new post
hugo new post/first-post.md

# build
npm run-script build

npm run-script deploy

#check deploy status
npm run-script deploystatus

Now it is really easy to add a new post and simply publish it in single command. If you found any other way to simplify , Please put in comments.

Happy Blogging :)

Load Comments?