Hugo and AWS/S3
This site, and a few others I have, are built using Hugo. Until today, I have been hosting the sites on a spare Raspberry Pi I had lying around at home. That is all well and good, but I think I want something more robust.
So today, I have moved the site to AWS using S3. There are a lot of tutorials/guides on how to do this, and here is my summary.
- Set up a bucket on S3. The name should be the same name as the site; e.g. in this case it it
- On S3, configure the bucket to be a static website, and set-up the Index Document to be
index.htmland the Error Document to be
404.html(or what ever matches your configuration
- Copy your local site (typically in the public directory of your hugo installation) to S3. I use
s3cmd put -P --recursive public/ s3://petersmith.org
- Change your DNS to point to the S3 bucket. Specifically, set a CNAME
record to point to the S3 bucket. The bucket will have a name something like
Then you are done.
If you want to have https on your site, then that is another story. You will still set up S3, but then you also need to set up CloudFront. That is something for another day.
I did a bad bad thing and my email stopped working. If you point your naked domain (in my case petersmith.org) to AWS, it effectively masks the MX records in the DNS, and so mail stops working.
The right thing to do is:
- Set up a bucket with a name like
www.petersmith.organd put all the content there.
- On your DNS set up a CNAME record for www pointing to the new S3 bucket; i.e.,
- Set a A record on the DNS to point to
126.96.36.199at wwwizer. It's not their main business but it works.