Amazon S3 allows you to host a static website like Hugo. To host a static website, you need to configure an Amazon S3 bucket for website hosting and upload the site content in the bucket. You can access the website either via the Amazon S3 website endpoint or via your own domain if you have one.

Hosting Hugo in S3

Here’s the list of what you will need:

  • An AWS Account
  • A domain name. For my case, I have my own domain from Amazon Route 53.
  • A GitHub account

Step 1

Create a bucket in S3. In AWS Console, go to Amazon S3. Click Create bucket.

Hosting Hugo in S3

The name of your bucket should be your domain name (e.g. www.enzobercasio.com). You can select the region closest to your location. Accept all the defaults first and we’ll modify them after the bucket creation.

Once the bucket is created, we need to modify the Permissions to make it public. Click on the created bucket and go to the Permissions tab. Uncheck the Block all public access option.

Hosting Hugo in S3

To create a policy, click on the bucket policy and paste the following:

  {
      "Version": "2008-10-17",
      "Statement": [
          {
              "Sid": "AllowPublicRead",
              "Effect": "Allow",
              "Principal": {
                  "AWS": "*"
              },
              "Action": "s3:GetObject",
              "Resource": "arn:aws:s3:::www.enzobercasio.com/*"
          }
      ]
  }

Remember to change the Resource to your own ARN arn:aws:s3:::www.change_me.com/*. Click Save.

Then, we need to set the bucket for Static Website Hosting. Go to Properties tab and click Static website hosting.

Hosting Hugo in S3

Click Use this bucket to host a website and set the Index document to Index.html. Click save.

Step 2

Upload the Hugo website public files to S3 bucket. To build your Hugo website files to the public/ folder, run command:

  $ hugo

Go back to the Amazon S3 and drag everything inside the public folder to upload.

Step 3

Direct your domain to your S3 bucket. In AWS Route 53, click on your domain name under the hosted zones.

Create an A-Type record set and set the Alias Target to your S3 bucket endpoint. Save the record set.

Hosting Hugo in S3

Now, you should be able to view your new Hugo website using your own domain name.