Host on AWS Amplify
In this guide we’ll walk through how to deploy and host your Hugo site using the AWS Amplify Console.
AWS Amplify is a combination of client library, CLI toolchain, and a Console for continuous deployment and hosting. The Amplify CLI and library allow developers to get up & running with full-stack cloud-powered applications with features like authentication, storage, serverless GraphQL or REST APIs, analytics, Lambda functions, & more. The Amplify Console provides continuous deployment and hosting for modern web apps (single page apps and static site generators). Continuous deployment allows developers to deploy updates to their web app on every code commit to their Git repository. Hosting includes features such as globally available CDNs, easy custom domain setup + HTTPS, feature branch deployments, and password protection.
Pre-requisites
- Sign up for an AWS Account. There are no upfront charges or any term commitments to create an AWS account and signing up gives you immediate access to the AWS Free Tier.
- You have an account with GitHub, GitLab, or Bitbucket.
- You have completed the Quick Start or have a Hugo website you are ready to deploy and share with the world.
Hosting
Log in to the AWS Amplify Console and choose Get Started under Deploy.
Connect a branch from your GitHub, Bitbucket, GitLab, or AWS CodeCommit repository. Connecting your repository allows Amplify to deploy updates on every code commit to a branch.
Accept the default build settings. The Amplify Console automatically detects your Hugo build settings and output directory.
Review your changes and then choose Save and deploy. The Amplify Console will pull code from your repository, build changes to the backend and frontend, and deploy your build artifacts at
https://master.unique-id.amplifyapp.com
. Bonus: Screenshots of your app on different devices to find layout issues.
Using a Newer Version of Hugo
If you need to use a different, perhaps newer, version of Hugo than the version currently supported by AWS Amplify, you can modify your build commands to include the downloading of Hugo itself. Here’s an example of a build definition that includes the downloading of Hugo. Note that in ths example the “extended” version of Hugo is being used which includes support for SASS/SCSS.
version: 0.1
frontend:
phases:
# IMPORTANT - Please verify your build commands
build:
commands:
- wget https://github.com/gohugoio/hugo/releases/download/v0.62.2/hugo_extended_0.62.2_Linux-64bit.tar.gz
- tar -xf hugo_extended_0.62.2_Linux-64bit.tar.gz
- mv hugo /usr/bin/hugo
- rm -rf hugo_extended_0.62.2_Linux-64bit.tar.gz
- hugo version
- hugo
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: public
files:
- '**/*'
cache:
paths: []