Build failed:get_author_name.html:26: function "return" not defined

Hi,

I built my personal website using the hugo academic as the template. The website can be launched locally in the RStudio by running blogdown::serve_site without any problems. When I tried to deploy my website following the tutorial on the hugo website, the build failed. There was an error saying “parse failed: template: partials/functions/get_author_name.html:26: function “return” not defined”. I googled it but found nothing. I also checked the common issues and the common configurations but I didn’t find solutions.

Below is the deploy log:

10:59:45 PM: Build ready to start
10:59:48 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
10:59:48 PM: build-image tag: v3.3.2
10:59:48 PM: buildbot version: a2bab682ae0761baa4d123ebd00c57be933655dc
10:59:48 PM: Fetching cached dependencies
10:59:48 PM: Starting to download cache of 255.0KB
10:59:48 PM: Finished downloading cache in 89.262943ms
10:59:48 PM: Starting to extract cache
10:59:48 PM: Failed to fetch cache, continuing with build
10:59:48 PM: Starting to prepare the repo for build
10:59:48 PM: No cached dependencies found. Cloning fresh repo
10:59:48 PM: git clone https://github.com/yanxianl/personal_website
10:59:51 PM: Preparing Git Reference refs/heads/master
10:59:51 PM: Starting build script
10:59:51 PM: Installing dependencies
10:59:53 PM: Downloading and installing node v10.17.0…
10:59:53 PM: Downloading https://nodejs.org/dist/v10.17.0/node-v10.17.0-linux-x64.tar.xz
10:59:54 PM:
######### 12.9%
10:59:54 PM:
############################
10:59:54 PM: 39.0%
10:59:54 PM:

10:59:54 PM: ##################################################### 79.5%
10:59:54 PM:
############################
10:59:54 PM: ############################################ 100.0%
10:59:54 PM: Computing checksum with sha256sum
10:59:54 PM: Checksums matched!
10:59:57 PM: Now using node v10.17.0 (npm v6.11.3)
10:59:57 PM: Attempting ruby version 2.6.2, read from environment
10:59:59 PM: Using ruby version 2.6.2
10:59:59 PM: Using PHP version 5.6
10:59:59 PM: Started restoring cached go cache
10:59:59 PM: Finished restoring cached go cache
11:00:00 PM: unset GOOS;
11:00:00 PM: unset GOARCH;
11:00:00 PM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
11:00:00 PM: export PATH=“/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}”;
11:00:00 PM: go version >&2;
11:00:00 PM: export GIMME_ENV=‘/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
11:00:00 PM: go version go1.12 linux/amd64
11:00:00 PM: Installing missing commands
11:00:00 PM: Verify run directory
11:00:00 PM: Executing user command: hugo
11:00:00 PM: Error: “/opt/build/repo/themes/hugo-academic/layouts/partials/functions/get_author_name.html:26:1”: parse failed: template: partials/functions/get_author_name.html:26: function “return” not defined
11:00:00 PM: Skipping functions preparation step: no functions directory set
11:00:00 PM: Caching artifacts
11:00:00 PM: Started saving pip cache
11:00:00 PM: Finished saving pip cache
11:00:00 PM: Started saving emacs cask dependencies
11:00:00 PM: Finished saving emacs cask dependencies
11:00:00 PM: Started saving maven dependencies
11:00:00 PM: Finished saving maven dependencies
11:00:00 PM: Started saving boot dependencies
11:00:00 PM: Finished saving boot dependencies
11:00:00 PM: Started saving go dependencies
11:00:00 PM: Finished saving go dependencies
11:00:03 PM: Error running command: Build script returned non-zero exit code: 255
11:00:03 PM: Failing build: Failed to build site
11:00:03 PM: failed during stage ‘building site’: Build script returned non-zero exit code: 255
11:00:04 PM: Finished processing build request in 15.870883828s

Yanxian

That kind of error generally means either syntax error in your templates/partials, or wrong version of hugo. When you set a version of hugo, we mention it explicitly in the build logs, and I don’t see that mention.

Might try picking a version of hugo using the method mentioned here:

to make sure the version we use matches your local.

1 Like

Hi, specify the hugo version installed in my PC in the netlify.toml file and add it to my project root folder solved the problem. Many thanks!

1 Like