Skip to content

Instantly share code, notes, and snippets.

@DirtyF
Last active September 1, 2021 16:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DirtyF/4f89704ecd619c0dcd439d74115da542 to your computer and use it in GitHub Desktop.
Save DirtyF/4f89704ecd619c0dcd439d74115da542 to your computer and use it in GitHub Desktop.
Bash script to run Hugo with support for Hugo modules on Vercel
#!/bin/bash
# default versions
if [ -z $GO_VERSION ]; then GO_VERSION='1.15.5'; fi
if [ -z $HUGO_VERSION ]; then HUGO_VERSION='0.80.0'; fi
# install Go
curl -sSOL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
# install Hugo
echo "Installing Hugo $HUGO_VERSION..."
curl -sSOL https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz
tar -xzf hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz
./hugo version
# run Hugo
echo "Running Hugo..."
./hugo --gc --minify
{
"builds": [
{
"src": "hugo-build.sh",
"use": "@vercel/static-build",
"config": { "distDir": "public" }
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment