Static site generation Why? When? How?

Dynamic sites are slower, expensive, complex, hackable.

When? If the site is mostly content and no heavy communication with server to update / calculate content in realtime.

Best use case, Portfolio website, company website, blogs, etc.

Static site generation with Gatsby

Gatsby is powerful tool to create static sites powered by GraphQL and ReactJs. It provides SEO, PWA out of the box and has lots of starter kit for different type of sites.

Static site generation for WordPress site

My personal blog is using WordPress. As it was and probably is go to tool to build a blog site.

Recently the site started facing some server issue and I was unable to access the admin panel. Because of that I could not post anything to my blog and update the about page for a year and finally I decided to get the site running on my local machine and generate static site with gatsby and check if it gets somewhere. At this point it was just an experiment.

The first thought was to write a new node type with custom resolver that will query the mysql. But I found out that there is a wordpress plugin for Gatsby. It made it very easy and saved me lots of time.

Completing the static site with contact form

After generating the static website, one very important part of the website was still missing, which was contact page. I could have used any third party services. But I wanted to build it by myself. For that you will need a server, or not. I saw this as the perfect opportunity to use serverless in real life 😉 I had been playing with AWS serverless services for a while but did not have a usecase to actually build something.

The next chapter is to build a serverless app that will accept POST request from our static site and save it on DynamoDB which is a noSQL DB from AWS.

Update: The Gatsby + WordPress adventure continues here…