Customize the build for Hugo running on AWS Amplify

January 1, 2020

When you deploy a Hugo framework on AWS Amplify, by default an old version of Hugo is used. I prefer to work with the latest version, but also to control the exact version to work with on my workstation and on production. That's why I created a custom deployment script you can find below. Just put it in the root of your application repository.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
version: 0.1
frontend:
  phases:
    build:
      commands:
        - wget --quiet https://github.com/gohugoio/hugo/releases/download/v0.62.0/hugo_extended_0.62.0_Linux-64bit.tar.gz
        - tar -xf hugo_extended_0.62.0_Linux-64bit.tar.gz hugo
        - mv hugo /usr/bin/hugo
        - rm -rf hugo_extended_0.62.0_Linux-64bit.tar.gz
        - which hugo
        - hugo version
        - hugo -b "https://hitthecloudrunning.com/"
  artifacts:
    baseDirectory: /public/
    files:
      - '**/*'
  cache:
    paths: []

Either it's not possible, or I haven't found the solution for using variables throughout the build script. As far as I know it's also not possible to retrieve the domain name for your website to use the same build script for your staging and live websites. If you can help me, please let me know! I'll update this blog post asap.

-Martijn

Photo by Kai Oberhäuser on Unsplash.

Author(s)
Martijn van Dongen
AWS Cloud Evangelist
Company
HitTheCloudRunning
Lage Hoek 112, 1689CP Zwaag

KVK: 77233514
VAT: NL003167220B95
Contact
Martijn van Dongen
Free Agent / AWS Cloud Architect

+31651175017
martijn@hitthecloudrunning.com