11#! /usr/bin/env bash
22
3+ # ------------------------------------------------------------------------------
4+ # @file
5+ # Builds a Hugo site hosted on a Cloudflare Worker.
6+ #
7+ # The Cloudflare Worker build image already includes Go, Hugo (an old version),
8+ # and Node js. Set the desired Dart Sass and Hugo versions below.
9+ #
10+ # The Cloudflare Worker automatically installs Node.js dependencies.
11+ # ------------------------------------------------------------------------------
12+
313main () {
4- Hugo_VERSION=" 0.148.1"
5- DART_SASS_VERSION=" 1.89.2"
614
7- export TZ=" Europe/Berlin"
15+ DART_SASS_VERSION=1.89.2
16+ HUGO_VERSION=0.148.0
17+
18+ export TZ=Europe/Oslo
819
920 # Install Dart Sass
1021 echo " Installing Dart Sass v${DART_SASS_VERSION} ..."
@@ -20,25 +31,26 @@ main() {
2031 cp hugo /opt/buildhome
2132 rm LICENSE README.md hugo_extended_${HUGO_VERSION} _linux-amd64.tar.gz
2233
23-
2434 # Set PATH
2535 echo " Setting the PATH environment variable..."
2636 export PATH=/opt/buildhome:/opt/buildhome/dart-sass:$PATH
2737
28- echo " Hugo version $Hugo_VERSION installed successfully."
38+ # Verify installed versions
39+ echo " Verifying installations..."
2940 echo Dart Sass: " $( sass --version) "
30- echo Go: " ${go version} "
31- echo " Hugo version: $( hugo version) "
32- echo Node.js version: " $( node -v) "
33- echo NPM version: " $( npm -v) "
41+ echo Go: " $( go version) "
42+ echo Hugo: " $( hugo version) "
43+ echo Node.js: " $( node --version) "
3444
3545 # https://gohugo.io/methods/page/gitinfo/#hosting-considerations
3646 git fetch --recurse-submodules --unshallow
3747
48+ # https://github.com/gohugoio/hugo/issues/9810
3849 git config core.quotepath false
3950
40- echo " Building site... "
51+ # Build the site.
4152 hugo --gc --minify
53+
4254}
4355
4456set -euo pipefail
0 commit comments