Can't Deploy Hugo on Netlify

I can’t deploy my Hugo site, i’ve tried using the GitHub and Gitlab repo, but still doesn’t work. I’m using version = hugo v0.117.0-b2f0696cad918fb61420a6aff173eb36662b406e+extended windows/amd64 BuildDate=2023-08-07T12:49:48Z VendorInfo=gohugoio

1:59:50 PM: build-image version: 20e1f1f500e4cbad9ea8a99bd40807bef3093551 (focal)
1:59:50 PM: buildbot version: 00a030bf3c001e3c0d5d2d5931d77655af9653ed
1:59:50 PM: Fetching cached dependencies
1:59:50 PM: Failed to fetch cache, continuing with build
1:59:50 PM: Starting to prepare the repo for build
1:59:51 PM: No cached dependencies found. Cloning fresh repo
1:59:51 PM: git clone --filter=blob:none git@gitlab.com:dhifaf/portfolio
1:59:52 PM: Preparing Git Reference refs/heads/master
1:59:54 PM: Starting to install dependencies
1:59:54 PM: Python version set to 3.8
1:59:54 PM: Attempting Ruby version 2.7.2, read from environment
1:59:55 PM: Using Ruby version 2.7.2
1:59:55 PM: Started restoring cached go cache
1:59:55 PM: Finished restoring cached go cache
1:59:57 PM: Installing Go version 1.19.12 (requested 1.19.x)
2:00:01 PM: go version go1.19.12 linux/amd64
2:00:02 PM: Using PHP version 8.0
2:00:03 PM: Downloading and installing node v18.17.1…
2:00:03 PM: Downloading https://nodejs.org/dist/v18.17.1/node-v18.17.1-linux-x64.tar.xz
2:00:03 PM: Computing checksum with sha256sum
2:00:03 PM: Checksums matched!
2:00:05 PM: Now using node v18.17.1 (npm v9.6.7)
2:00:05 PM: Enabling Node.js Corepack
2:00:05 PM: Started restoring cached build plugins
2:00:05 PM: Finished restoring cached build plugins
2:00:06 PM: Install dependencies script success
2:00:06 PM: Starting build script
2:00:06 PM: Detected 1 framework(s)
2:00:06 PM: hugo at version unknown
2:00:06 PM: Section completed: initializing
2:00:10 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
2:00:08 PM: ​
2:00:08 PM: Netlify Build
2:00:08 PM: ────────────────────────────────────────────────────────────────
2:00:08 PM: ​
2:00:08 PM: ❯ Version
2:00:08 PM: @netlify/build 29.19.0
2:00:08 PM: ​
2:00:08 PM: ❯ Flags
2:00:08 PM: baseRelDir: true
2:00:08 PM: buildId: 64d9d0e5f606f90eaefbc2db
2:00:08 PM: deployId: 64d9d0e5f606f90eaefbc2dd
2:00:08 PM: ​
2:00:08 PM: ❯ Current directory
2:00:08 PM: /opt/build/repo
2:00:08 PM: ​
2:00:08 PM: ❯ Config file
2:00:08 PM: No config file was defined: using default values.
2:00:08 PM: ​
2:00:08 PM: ❯ Context
2:00:08 PM: production
2:00:08 PM: ​
2:00:08 PM: Build command from Netlify app
2:00:08 PM: ────────────────────────────────────────────────────────────────
2:00:08 PM: ​
2:00:08 PM: $ hugo
2:00:08 PM: Error: Unable to locate config file or config directory. Perhaps you need to create a new site.
2:00:08 PM: Run hugo help new for details.
2:00:08 PM: Total in 3 ms
2:00:08 PM: ​
2:00:08 PM: build.command failed
2:00:08 PM: ────────────────────────────────────────────────────────────────
2:00:08 PM: ​
2:00:08 PM: Error message
2:00:08 PM: Command failed with exit code 255: hugo (Search results for '"non-zero exit code: 255"' - Netlify Support Forums)
2:00:08 PM: ​
2:00:08 PM: Error location
2:00:08 PM: In Build command from Netlify app:
2:00:08 PM: hugo
2:00:08 PM: ​
2:00:08 PM: Resolved config
2:00:08 PM: build:
2:00:08 PM: command: hugo
2:00:08 PM: commandOrigin: ui
2:00:08 PM: publish: /opt/build/repo/public
2:00:08 PM: publishOrigin: ui
2:00:09 PM: Caching artifacts
2:00:09 PM: Started saving build plugins
2:00:09 PM: Finished saving build plugins
2:00:09 PM: Started saving pip cache
2:00:09 PM: Finished saving pip cache
2:00:09 PM: Started saving emacs cask dependencies
2:00:09 PM: Finished saving emacs cask dependencies
2:00:09 PM: Started saving maven dependencies
2:00:09 PM: Finished saving maven dependencies
2:00:09 PM: Started saving boot dependencies
2:00:09 PM: Finished saving boot dependencies
2:00:09 PM: Started saving rust rustup cache
2:00:09 PM: Finished saving rust rustup cache
2:00:09 PM: Started saving go dependencies
2:00:09 PM: Finished saving go dependencies
2:00:10 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:00:10 PM: Failing build: Failed to build site
2:00:11 PM: Finished processing build request in 20.435s

Hi @diszyfoxx,

Thanks for reaching out and welcome to Netlify’s Support Forums!

I’m seeing an error here:

2:00:08 AM: $ hugo
2:00:08 AM: Error: Unable to locate config file or config directory. Perhaps you need to create a new site.
2:00:08 AM:        Run `hugo help new` for details.

I found this past Netlify Support Forum post that may help:

Let us know if you continue to have issues.

Thanks for the answer, my problem solved by adding HUGO_VERSION to enviroment variable.

Hi @diszyfoxx,

Thank you for letting us know how you resolved the issue. I hope you have a great day!