Academia - Hugo build failure

Hi Team,

I am getting the following build error while deploying Hugo app on Netlify. I am very new to Hugo and Netlify and must have made some errors somewhere. This works just fine on localhost, however it fails while deploying on Netlify. Please note, I am using β€œhttps://themes.gohugo.io/academia-hugo/” theme to be specific. Any suggestions are highly appreciated.

Thanks,
Pranav

10:59:46 AM: Build ready to start
10:59:48 AM: build-image version: 9d79ad851d6eff3969322d6e5b1df3d597650c41
10:59:48 AM: build-image tag: v3.3.19
10:59:48 AM: buildbot version: 2cc7ea668a3e8f63326d15aab17e62cd1997fa2e
10:59:48 AM: Fetching cached dependencies
10:59:48 AM: Starting to download cache of 254.7KB
10:59:48 AM: Finished downloading cache in 68.636413ms
10:59:48 AM: Starting to extract cache
10:59:48 AM: Failed to fetch cache, continuing with build
10:59:48 AM: Starting to prepare the repo for build
10:59:48 AM: No cached dependencies found. Cloning fresh repo
10:59:48 AM: git clone https://github.com/Pranavbawa/portfolio2
10:59:49 AM: Preparing Git Reference refs/heads/master
10:59:51 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'hugo --gc --minify' versus '"hugo --gc --minify"' in the Netlify UI
10:59:51 AM: Starting build script
10:59:51 AM: Installing dependencies
10:59:51 AM: Python version set to 2.7
10:59:52 AM: v12.18.0 is already installed.
10:59:52 AM: Now using node v12.18.0 (npm v6.14.4)
10:59:53 AM: Started restoring cached build plugins
10:59:53 AM: Finished restoring cached build plugins
10:59:53 AM: Attempting ruby version 2.7.1, read from environment
10:59:54 AM: Using ruby version 2.7.1
10:59:54 AM: Using PHP version 5.6
10:59:54 AM: 5.2 is already installed.
10:59:54 AM: Using Swift version 5.2
10:59:54 AM: Installing Hugo 0.55.0
10:59:56 AM: Hugo Static Site Generator v0.55.0-4333CC77F/extended linux/amd64 BuildDate: 2019-04-08T17:05:23Z
10:59:56 AM: Started restoring cached go cache
10:59:56 AM: Finished restoring cached go cache
10:59:56 AM: go version go1.14.4 linux/amd64
10:59:56 AM: go version go1.14.4 linux/amd64
10:59:56 AM: Installing missing commands
10:59:56 AM: Verify run directory
10:59:57 AM: ​
10:59:57 AM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
10:59:57 AM: β”‚        Netlify Build        β”‚
10:59:57 AM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10:59:57 AM: ​
10:59:57 AM: ❯ Version
10:59:57 AM:   @netlify/build 2.0.25
10:59:57 AM: ​
10:59:57 AM: ❯ Flags
10:59:57 AM:   deployId: 5f04b812b3afe565edb5fac0
10:59:57 AM:   mode: buildbot
10:59:57 AM: ​
10:59:57 AM: ❯ Current directory
10:59:57 AM:   /opt/build/repo
10:59:57 AM: ​
10:59:57 AM: ❯ Config file
10:59:57 AM:   /opt/build/repo/netlify.toml
10:59:57 AM: ​
10:59:57 AM: ❯ Context
10:59:57 AM:   production
10:59:57 AM: ​
10:59:57 AM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
10:59:57 AM: β”‚ 1. build.command from netlify.toml β”‚
10:59:57 AM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10:59:57 AM: ​
10:59:57 AM: $ hugo --gc --minify
10:59:57 AM: Building sites … Total in 1 ms
10:59:57 AM: Error: Error building site: open /opt/build/repo/content: no such file or directory
10:59:57 AM: ​
10:59:57 AM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
10:59:57 AM: β”‚   "build.command" failed    β”‚
10:59:57 AM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
10:59:57 AM: ​
10:59:57 AM:   Error message
10:59:57 AM:   Command failed with exit code 255: hugo --gc --minify
10:59:57 AM: ​
10:59:57 AM:   Error location
10:59:57 AM:   In build.command from netlify.toml:
10:59:57 AM:   hugo --gc --minify
10:59:57 AM: ​
10:59:57 AM:   Resolved config
10:59:57 AM:   build:
10:59:57 AM:     command: hugo --gc --minify
10:59:57 AM:     commandOrigin: config
10:59:57 AM:     environment:
10:59:57 AM:       - HUGO_VERSION
10:59:57 AM:       - HUGO_ENV
10:59:57 AM:       - HUGO_ENABLEGITINFO
10:59:57 AM:     publish: /opt/build/repo/public
10:59:57 AM: Caching artifacts
10:59:57 AM: Started saving build plugins
10:59:57 AM: Finished saving build plugins
10:59:57 AM: Started saving pip cache
10:59:57 AM: Finished saving pip cache
10:59:57 AM: Started saving emacs cask dependencies
10:59:57 AM: Finished saving emacs cask dependencies
10:59:57 AM: Started saving maven dependencies
10:59:57 AM: Finished saving maven dependencies
10:59:57 AM: Started saving boot dependencies
10:59:57 AM: Finished saving boot dependencies
10:59:57 AM: Started saving go dependencies
10:59:57 AM: Finished saving go dependencies
11:00:00 AM: Error running command: Build script returned non-zero exit code: 1
11:00:00 AM: Failing build: Failed to build site
11:00:00 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
11:00:00 AM: Finished processing build request in 11.720149997s

Hey @pranav_bawa,
I took a look at your repo (https://github.com/Pranavbawa/portfolio2) and those files look like they have already been through your Hugo theme’s processing: there is an index.html file linking to your Javascript, CSS, etc. So the site has already been built, it just needs to be deployed on Netlify. Since this is the case, you can remove your build command from the netlify.toml- and you may not need the netlify.toml at all.

If in the future you’d like for Netlify to build your site (instead of just deploying your already-built site), you would add the build command back in and deploy your whole repo, including Hugo theme files.

If you’re new to Hugo and Netlify, you may fare better with a theme that has better documentation. It looks like your current theme, Academia, is forked from Academic, which has lots of docs:
https://sourcethemes.com/academic/docs/

Let us know if this helps or if you have other questions!

1 Like

Thank you for your reply @jen! I removed the netlify.toml and the site is deployed without errors now. However, although the content is there on the live page, the site is not rendering the css/theme that it should. Is there something I am missing here? Thanks in advance for your next reply :slight_smile:

You’ll need to make sure that any references to your CSS are pointing to the right path :slight_smile: I see in your HTML that you’re referencing your .css file directly in GitHub. You’ll need to reference the path of your website, not the file on GitHub (unless you use the β€˜raw’ link but it’s still best to serve straight from your site)!