Auto-Deploying Static Site to S3

Static websites have a lot of advantages compared to dynamic web applications: easier to develop, cheaper to host, and better indexing for SEO. Performance is arguable; you might be able to match the TTFB and throughput of a static site with a well-configured reverse proxy, but why bother?

My Approach

There are a lot of options for developing and hosting a static site but this is what I went with for my website (the one you’re on!):

Set-Up

Before auto-deploying with Pipelines, a couple of things need to be set up. There are a lot of guides on generating a basic site with Hugo, so I won’t go over it. The structure of the content directory is the most important thing because it will determine the site layout; this is what I’m using:

$ tree content
content
├── _index.md
└── blog
    ├── deploy_static.md
    ├── ...
    └── ...

All that’s needed before deploying and hosting on S3 is generating the actual web artifacts with the hugo command. The contents of the generated public/ directory can then be uploaded to S3.