Failed to deploy Hugo theme. Exit code 2

I’m trying to deploy my blog using Netlify but I got the following results:

3:46:35 PM: Build ready to start
3:46:37 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
3:46:37 PM: build-image tag: v4.5.3
3:46:37 PM: buildbot version: c68dbedb54f97d2ade6b8aa44f524f50c2bf9351
3:46:38 PM: Fetching cached dependencies
3:46:38 PM: Failed to fetch cache, continuing with build
3:46:38 PM: Starting to prepare the repo for build
3:46:39 PM: No cached dependencies found. Cloning fresh repo
3:46:39 PM: git clone git@gitlab.com:rogerlop/personal-blog
3:46:39 PM: Preparing Git Reference refs/heads/main
3:46:40 PM: Parsing package.json dependencies
3:46:41 PM: Starting build script
3:46:41 PM: Installing dependencies
3:46:41 PM: Python version set to 2.7
3:46:41 PM: Downloading and installing node v16.14.0...
3:46:41 PM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz...
3:46:42 PM: Computing checksum with sha256sum
3:46:42 PM: Checksums matched!
3:46:44 PM: Now using node v16.14.0 (npm v8.3.1)
3:46:45 PM: Started restoring cached build plugins
3:46:45 PM: Finished restoring cached build plugins
3:46:45 PM: Attempting ruby version 2.7.2, read from environment
3:46:46 PM: Using ruby version 2.7.2
3:46:46 PM: Using PHP version 8.0
3:46:46 PM: Started restoring cached go cache
3:46:46 PM: Finished restoring cached go cache
3:46:46 PM: go version go1.16.5 linux/amd64
3:46:46 PM: go version go1.16.5 linux/amd64
3:46:46 PM: Installing missing commands
3:46:46 PM: Verify run directory
3:46:47 PM: ​
3:46:47 PM: ────────────────────────────────────────────────────────────────
3:46:47 PM:   Netlify Build                                                 
3:46:47 PM: ────────────────────────────────────────────────────────────────
3:46:47 PM: ​
3:46:47 PM: ❯ Version
3:46:47 PM:   @netlify/build 26.3.14
3:46:47 PM: ​
3:46:47 PM: ❯ Flags
3:46:47 PM:   baseRelDir: true
3:46:47 PM:   buildId: 6223be1a4fb3d7476f1bdd1d
3:46:47 PM:   deployId: 6223be1a4fb3d7476f1bdd1f
3:46:47 PM: ​
3:46:47 PM: ❯ Current directory
3:46:47 PM:   /opt/build/repo
3:46:47 PM: ​
3:46:47 PM: ❯ Config file
3:46:47 PM:   No config file was defined: using default values.
3:46:47 PM: ​
3:46:47 PM: ❯ Context
3:46:47 PM:   production
3:46:47 PM: ​
3:46:47 PM: ────────────────────────────────────────────────────────────────
3:46:47 PM:   1. Build command from Netlify app                             
3:46:47 PM: ────────────────────────────────────────────────────────────────
3:46:47 PM: ​
3:46:47 PM: $ hugo
3:46:47 PM: Error: Unable to locate config file or config directory. Perhaps you need to create a new site.
3:46:47 PM:        Run `hugo help new` for details.
3:46:47 PM: Total in 0 ms
3:46:47 PM: ​
3:46:47 PM: ────────────────────────────────────────────────────────────────
3:46:47 PM:   "build.command" failed                                        
3:46:47 PM: ────────────────────────────────────────────────────────────────
3:46:47 PM: ​
3:46:47 PM:   Error message
3:46:47 PM:   Command failed with exit code 255: hugo
3:46:47 PM: ​
3:46:47 PM:   Error location
3:46:47 PM:   In Build command from Netlify app:
3:46:47 PM:   hugo
3:46:47 PM: ​
3:46:47 PM:   Resolved config
3:46:47 PM:   build:
3:46:47 PM:     command: hugo
3:46:47 PM:     commandOrigin: ui
3:46:47 PM:     publish: /opt/build/repo/public
3:46:47 PM:     publishOrigin: ui
3:46:48 PM: Caching artifacts
3:46:48 PM: Started saving build plugins
3:46:48 PM: Finished saving build plugins
3:46:48 PM: Started saving pip cache
3:46:48 PM: Finished saving pip cache
3:46:48 PM: Started saving emacs cask dependencies
3:46:48 PM: Finished saving emacs cask dependencies
3:46:48 PM: Started saving maven dependencies
3:46:48 PM: Finished saving maven dependencies
3:46:48 PM: Started saving boot dependencies
3:46:50 PM: Creating deploy upload records
3:46:48 PM: Finished saving boot dependencies
3:46:48 PM: Started saving rust rustup cache
3:46:48 PM: Finished saving rust rustup cache
3:46:48 PM: Started saving go dependencies
3:46:48 PM: Finished saving go dependencies
3:46:49 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:46:50 PM: Failing build: Failed to build site
3:46:50 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
3:46:51 PM: Finished processing build request in 13.086826088s

I don’t know what else I have to do. I’ve been looking for answer in many blogs and trying different things but it seems like nobody has had this exact error.

First, even though there’s a config.toml in my repo Netlify seems not to cacht it (also I added a netlify.toml to give specific settings for deploy but nothing). However, I can deploy my site locally.

Here is the link to my repo: https://gitlab.com/rogerlop/personal-blog

Thanks beforehand for your help

Your config.toml seems to be in a subfolder

You may also want to use https (instead of http) everywhere