Hugo build error with HUGO_ENV variable results in errors, requires extended version of hugo

Is it possible to use the extended version of hugo on netlify?

Netlify site: https://upbeat-lamport-86d9b0.netlify.app/
Custom DNS: https://hackerunder.dev
Github repo: GitHub - Greenjam94/HackerUnderDev: Personal infosec blog using Hugo static site generator
Github sub module: GitHub - theNewDynamic/gohugo-theme-ananke: Ananke: A theme for Hugo Sites

Initial investigation: Google is unable to index site because of tags containing noindex. Reviewed the submodule for the theme in use and that is what’s causing the meta tag value.

Ananke theme README.md says:

To run in production (e.g. to have Google Analytics show up), run HUGO_ENV=production before your build command. For example:

HUGO_ENV=production hugo

So I’ve tried this in two ways, both which results in the same errors being returned.
Option 1: Include an environment variable in the netlify deploy settings.
name: HUGO_ENV
value: production

Option 2: Change the build command from hugo to HUGO_ENV=production hugo

Doing one of these two options is the only change made to my netlify config and this breaks the deployment and gives the error below. The site currently works because I’ve reverted the change.

11:44:45 PM: Error: Error building site: TOCSS: failed to transform "ananke/css/main.css" (text/css). Check your Hugo installation; you need the extended version to build SCSS/SASS.

I am unsure how to proceed, I don’t know if it’s possible to change the hugo installation on netlify to include the extended version. There is a similar hugo forum post asking for this but the answer was just “read the install docs” and I’m still not sure if that’s something I can modify on Netlify.

Full deploy error log:

11:44:31 PM: Build ready to start
11:44:33 PM: build-image version: 9289b698a503f132b265bd089ab40ce1d6f9e65e (focal)
11:44:33 PM: build-image tag: v4.12.0
11:44:33 PM: buildbot version: 2510ae842d7cc96532da2c05a74ba836f3e7f056
11:44:33 PM: Building without cache
11:44:33 PM: Starting to prepare the repo for build
11:44:33 PM: No cached dependencies found. Cloning fresh repo
11:44:33 PM: git clone https://github.com/Greenjam94/HackerUnderDev
11:44:34 PM: Preparing Git Reference refs/heads/master
11:44:35 PM: Parsing package.json dependencies
11:44:36 PM: Starting build script
11:44:36 PM: Installing dependencies
11:44:36 PM: Python version set to 2.7
11:44:36 PM: Downloading and installing node v16.18.0...
11:44:36 PM: Downloading https://nodejs.org/dist/v16.18.0/node-v16.18.0-linux-x64.tar.xz...
11:44:37 PM: Computing checksum with sha256sum
11:44:37 PM: Checksums matched!
11:44:39 PM: Now using node v16.18.0 (npm v8.19.2)
11:44:39 PM: Started restoring cached build plugins
11:44:39 PM: Finished restoring cached build plugins
11:44:39 PM: Attempting ruby version 2.7.2, read from environment
11:44:40 PM: Using ruby version 2.7.2
11:44:40 PM: Using PHP version 8.0
11:44:40 PM: Started restoring cached go cache
11:44:40 PM: Finished restoring cached go cache
11:44:40 PM: Installing Go version 1.16.5 (requested 1.16.5)
11:44:44 PM: unset GOOS;
11:44:44 PM: unset GOARCH;
11:44:44 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
11:44:44 PM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
11:44:44 PM: go version >&2;
11:44:44 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
11:44:44 PM: go version go1.16.5 linux/amd64
11:44:44 PM: Installing missing commands
11:44:44 PM: Verify run directory
11:44:45 PM: ​
11:44:45 PM: ────────────────────────────────────────────────────────────────
11:44:45 PM:   Netlify Build                                                 
11:44:45 PM: ────────────────────────────────────────────────────────────────
11:44:45 PM: ​
11:44:45 PM: ❯ Version
11:44:45 PM:   @netlify/build 27.20.6
11:44:45 PM: ​
11:44:45 PM: ❯ Flags
11:44:45 PM:   baseRelDir: true
11:44:45 PM:   buildId: 634e211fda78b37883aea3ed
11:44:45 PM:   deployId: 634e211fda78b37883aea3ef
11:44:45 PM: ​
11:44:45 PM: ❯ Current directory
11:44:45 PM:   /opt/build/repo
11:44:45 PM: ​
11:44:45 PM: ❯ Config file
11:44:45 PM:   No config file was defined: using default values.
11:44:45 PM: ​
11:44:45 PM: ❯ Context
11:44:45 PM:   production
11:44:45 PM: ​
11:44:45 PM: ────────────────────────────────────────────────────────────────
11:44:45 PM:   1. Build command from Netlify app                             
11:44:45 PM: ────────────────────────────────────────────────────────────────
11:44:45 PM: ​
11:44:45 PM: $ hugo
11:44:45 PM: Start building sites …
11:44:45 PM: hugo v0.85.0-724D5DB5 linux/amd64 BuildDate=2021-07-05T10:46:28Z VendorInfo=gohugoio
11:44:45 PM: Error: Error building site: TOCSS: failed to transform "ananke/css/main.css" (text/css). Check your Hugo installation; you need the extended version to build SCSS/SASS.
11:44:45 PM: Total in 194 ms
11:44:45 PM: ​
11:44:45 PM: ────────────────────────────────────────────────────────────────
11:44:45 PM:   "build.command" failed                                        
11:44:45 PM: ────────────────────────────────────────────────────────────────
11:44:45 PM: ​
11:44:45 PM:   Error message
11:44:45 PM:   Command failed with exit code 255: hugo (https://ntl.fyi/exit-code-255)
11:44:45 PM: ​
11:44:45 PM:   Error location
11:44:45 PM:   In Build command from Netlify app:
11:44:45 PM:   hugo
11:44:45 PM: ​
11:44:45 PM:   Resolved config
11:44:45 PM:   build:
11:44:45 PM:     command: hugo
11:44:45 PM:     commandOrigin: ui
11:44:45 PM:     environment:
11:44:45 PM:       - HUGO_ENV
11:44:45 PM:     publish: /opt/build/repo/public
11:44:45 PM:     publishOrigin: ui
11:44:45 PM: Caching artifacts
11:44:45 PM: Started saving build plugins
11:44:45 PM: Finished saving build plugins
11:44:45 PM: Started saving pip cache
11:44:45 PM: Finished saving pip cache
11:44:45 PM: Started saving emacs cask dependencies
11:44:46 PM: Finished saving emacs cask dependencies
11:44:46 PM: Started saving maven dependencies
11:44:46 PM: Finished saving maven dependencies
11:44:46 PM: Started saving boot dependencies
11:44:46 PM: Finished saving boot dependencies
11:44:46 PM: Started saving rust rustup cache
11:44:46 PM: Finished saving rust rustup cache
11:44:46 PM: Started saving go dependencies
11:44:46 PM: Finished saving go dependencies
11:44:46 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:44:46 PM: Creating deploy upload records
11:44:46 PM: Failing build: Failed to build site
11:44:46 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:44:47 PM: Finished processing build request in 13.939652262s

Another topic that is related to this or reporting the same concern about not using hugo extended

Hi @Greenjam94 and @user349340

Have you seen this post which offers a potential solution

Thank you @coelmay that did solve my problem.

By adding two environment variables, I am able to have a passing build! Only Version is needed to run extended hugo.

Variables:
HUGO_VERSION=0.85.0
HUGO_ENV=production

Check out these lines from build log

7:50:02 PM: Installing Hugo 0.85.0
7:50:03 PM: hugo v0.85.0-724D5DB5+extended linux/amd64 BuildDate=2021-07-05T10:46:28Z VendorInfo=gohugoio

At this point in the process, the failed build attempt didn’t log trying to install hugo at all. I wonder if something changed there.

Full build log:

7:49:52 PM: Build ready to start
7:49:57 PM: build-image version: d05976bd3309b73a86eaa327bf80e105ff13f5e4 (focal)
7:49:57 PM: build-image tag: v4.13.0
7:49:57 PM: buildbot version: 3a000de5d3727998f3297394596d287d7e49aecd
7:49:57 PM: Building without cache
7:49:57 PM: Starting to prepare the repo for build
7:49:58 PM: No cached dependencies found. Cloning fresh repo
7:49:58 PM: git clone https://github.com/Greenjam94/HackerUnderDev
7:49:59 PM: Preparing Git Reference refs/heads/master
7:50:00 PM: Parsing package.json dependencies
7:50:01 PM: Starting build script
7:50:01 PM: Installing dependencies
7:50:01 PM: Python version set to 2.7
7:50:01 PM: v16.18.0 is already installed.
7:50:02 PM: Now using node v16.18.0 (npm v8.19.2)
7:50:02 PM: Enabling node corepack
7:50:02 PM: Started restoring cached build plugins
7:50:02 PM: Finished restoring cached build plugins
7:50:02 PM: Attempting ruby version 2.7.2, read from environment
7:50:02 PM: Using ruby version 2.7.2
7:50:02 PM: Using PHP version 8.0
7:50:02 PM: Installing Hugo 0.85.0
7:50:03 PM: hugo v0.85.0-724D5DB5+extended linux/amd64 BuildDate=2021-07-05T10:46:28Z VendorInfo=gohugoio
7:50:03 PM: Started restoring cached go cache
7:50:03 PM: Finished restoring cached go cache
7:50:03 PM: Installing Go version 1.16.5 (requested 1.16.5)
7:50:08 PM: unset GOOS;
7:50:08 PM: unset GOARCH;
7:50:08 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
7:50:08 PM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
7:50:08 PM: go version >&2;
7:50:08 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
7:50:08 PM: go version go1.16.5 linux/amd64
7:50:08 PM: Installing missing commands
7:50:08 PM: Verify run directory
7:50:09 PM: ​
7:50:09 PM: ────────────────────────────────────────────────────────────────
7:50:09 PM:   Netlify Build                                                 
7:50:09 PM: ────────────────────────────────────────────────────────────────
7:50:09 PM: ​
7:50:09 PM: ❯ Version
7:50:09 PM:   @netlify/build 27.20.6
7:50:09 PM: ​
7:50:09 PM: ❯ Flags
7:50:09 PM:   baseRelDir: true
7:50:09 PM:   buildId: 634f3ba033f30413b8ad86ff
7:50:09 PM:   deployId: 634f3ba033f30413b8ad8701
7:50:10 PM: Creating deploy upload records
7:50:10 PM: ​
7:50:10 PM: ❯ Current directory
7:50:10 PM:   /opt/build/repo
7:50:10 PM: ​
7:50:10 PM: ❯ Config file
7:50:10 PM:   No config file was defined: using default values.
7:50:10 PM: ​
7:50:10 PM: ❯ Context
7:50:10 PM:   production
7:50:10 PM: ​
7:50:10 PM: ────────────────────────────────────────────────────────────────
7:50:10 PM:   1. Build command from Netlify app                             
7:50:10 PM: ────────────────────────────────────────────────────────────────
7:50:10 PM: ​
7:50:10 PM: $ hugo
7:50:10 PM: Start building sites …
7:50:10 PM: hugo v0.85.0-724D5DB5+extended linux/amd64 BuildDate=2021-07-05T10:46:28Z VendorInfo=gohugoio
7:50:10 PM:                    | EN
7:50:10 PM: -------------------+------
7:50:10 PM:   Pages            | 225
7:50:10 PM:   Paginator pages  |   9
7:50:10 PM:   Non-page files   |   0
7:50:10 PM:   Static files     | 426
7:50:10 PM:   Processed images |   0
7:50:10 PM:   Aliases          |   2
7:50:10 PM:   Sitemaps         |   1
7:50:10 PM:   Cleaned          |   0
7:50:10 PM: Total in 225 ms
7:50:10 PM: ​
7:50:10 PM: (build.command completed in 253ms)
7:50:10 PM: ​
7:50:10 PM: ────────────────────────────────────────────────────────────────
7:50:10 PM:   2. Deploy site                                                
7:50:10 PM: ────────────────────────────────────────────────────────────────
7:50:10 PM: ​
7:50:10 PM: Starting to deploy site from 'public'
7:50:10 PM: Creating deploy tree asynchronously
7:50:12 PM: 170 new files to upload
7:50:12 PM: 0 new functions to upload
7:50:12 PM: 0% complete
7:50:12 PM: 5% complete
7:50:12 PM: 10% complete
7:50:13 PM: 15% complete
7:50:13 PM: 20% complete
7:50:13 PM: 25% complete
7:50:13 PM: 30% complete
7:50:13 PM: 35% complete
7:50:13 PM: 40% complete
7:50:13 PM: 45% complete
7:50:13 PM: 50% complete
7:50:13 PM: 55% complete
7:50:14 PM: 60% complete
7:50:14 PM: 65% complete
7:50:14 PM: 70% complete
7:50:14 PM: 75% complete
7:50:14 PM: 80% complete
7:50:14 PM: 85% complete
7:50:14 PM: 90% complete
7:50:14 PM: 95% complete
7:50:14 PM: 100% complete
7:50:14 PM: Site deploy was successfully initiated
7:50:14 PM: ​
7:50:14 PM: (Deploy site completed in 4.6s)
7:50:14 PM: ​
7:50:14 PM: ────────────────────────────────────────────────────────────────
7:50:14 PM:   Netlify Build Complete                                        
7:50:14 PM: ────────────────────────────────────────────────────────────────
7:50:14 PM: ​
7:50:14 PM: (Netlify Build completed in 4.9s)
7:50:15 PM: Caching artifacts
7:50:15 PM: Started saving build plugins
7:50:15 PM: Finished saving build plugins
7:50:15 PM: Started saving pip cache
7:50:15 PM: Finished saving pip cache
7:50:15 PM: Started saving emacs cask dependencies
7:50:15 PM: Finished saving emacs cask dependencies
7:50:15 PM: Started saving maven dependencies
7:50:15 PM: Finished saving maven dependencies
7:50:15 PM: Started saving boot dependencies
7:50:15 PM: Finished saving boot dependencies
7:50:15 PM: Starting post processing
7:50:15 PM: Started saving rust rustup cache
7:50:15 PM: Finished saving rust rustup cache
7:50:15 PM: Started saving go dependencies
7:50:15 PM: Post processing - HTML
7:50:15 PM: Finished saving go dependencies
7:50:15 PM: Build script success
7:50:16 PM: Uploading Cache of size 195.2MB
7:50:17 PM: Finished processing build request in 20.086850088s
7:50:24 PM: Post processing - header rules
7:50:25 PM: Post processing - redirect rules
7:50:25 PM: Post processing done
7:50:28 PM: Site is live ✨

Checking the site at https://hackerunder.dev shows that the meta tag is updated to show “follow, index” and not “noindex”

Hey there, @Greenjam94 :wave:

Thanks for reaching out and confirming that @coelmay solved your problem! Let us know if you have any further questions.