[SOLVED] GetTerms Error when trying to use taxonomies

I’m trying to add tags to my blog posts and this is working locally when running hugo server -D using a taxonomy partial that is included in a single.html template.

Error: Error building site: failed to render pages: render of “page” failed: execute of template failed: template: posts/single.html:4:5: executing “main” at <partial "taxonomies…>: error calling partial: “/opt/build/repo/layouts/partials/taxonomies.html:3:14”: execute of template failed: template: partials/taxonomies.html:3:14: executing “partials/taxonomies.html” at <.GetTerms>: can’t evaluate field GetTerms in type *hugolib.PageOutput

Taxonomies partial

<ul class="taxonomies">
	<li>Taggar: </li>
    {{ range (.GetTerms "tags") }}
        <li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
   {{ end }}
</ul>

Per Post Config Attempt 1

title: “Title”
date: 2020-07-01T19:28:29+02:00
draft: false
tags:
- Tag1
- Tag2

Per Post Config Attempt 2

title: “Title”
date: 2020-07-01T19:28:29+02:00
draft: false
tags: [“Tag1”,“Tag2”]

Single template

Single template
{{ define "main" -}}
<div class="post">
  
  {{ partial "taxonomies.html" . }}

  <h1>{{ .Title }}</h1>
  <time datetime={{ .Date.Format "2006-01-02T15:04:05Z0700" }} class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</time>

  {{ .Content }}
</div>

{{ partial "socialshare.html" . }}

{{ if .Site.DisqusShortname -}}
<h2>Comments</h2>
{{ template "_internal/disqus.html" . }}
{{- end }}
{{- end }}

Building log

Log
10:29:28 AM: Build ready to start
10:29:30 AM: build-image version: 9d79ad851d6eff3969322d6e5b1df3d597650c41
10:29:30 AM: build-image tag: v3.3.19
10:29:30 AM: buildbot version: 2cc7ea668a3e8f63326d15aab17e62cd1997fa2e
10:29:30 AM: Fetching cached dependencies
10:29:30 AM: Starting to download cache of 216.1MB
10:29:32 AM: Finished downloading cache in 1.73702559s
10:29:32 AM: Starting to extract cache
10:29:39 AM: Finished extracting cache in 7.097402682s
10:29:39 AM: Finished fetching cache in 8.900649912s
10:29:39 AM: Starting to prepare the repo for build
10:29:40 AM: Preparing Git Reference refs/heads/master
10:29:44 AM: Starting build script
10:29:44 AM: Installing dependencies
10:29:44 AM: Python version set to 2.7
10:29:44 AM: Started restoring cached node version
10:29:47 AM: Finished restoring cached node version
10:29:48 AM: v10.21.0 is already installed.
10:29:49 AM: Now using node v10.21.0 (npm v6.14.4)
10:29:49 AM: Started restoring cached build plugins
10:29:49 AM: Finished restoring cached build plugins
10:29:49 AM: Attempting ruby version 2.6.2, read from environment
10:29:50 AM: Using ruby version 2.6.2
10:29:51 AM: Using PHP version 5.6
10:29:51 AM: 5.2 is already installed.
10:29:51 AM: Using Swift version 5.2
10:29:51 AM: Started restoring cached go cache
10:29:52 AM: Finished restoring cached go cache
10:29:52 AM: Installing Go version 1.12
10:29:52 AM: unset GOOS;
10:29:52 AM: unset GOARCH;
10:29:52 AM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64';
10:29:52 AM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64/bin:${PATH}";
10:29:52 AM: go version >&2;
10:29:52 AM: export GIMME_ENV='/opt/buildhome/.gimme_cache/env/go1.12.linux.amd64.env';
10:29:52 AM: go version go1.12 linux/amd64
10:29:52 AM: Installing missing commands
10:29:52 AM: Verify run directory
10:29:53 AM: ​
10:29:53 AM: ┌─────────────────────────────┐
10:29:53 AM: │        Netlify Build        │
10:29:53 AM: └─────────────────────────────┘
10:29:53 AM: ​
10:29:53 AM: ❯ Version
10:29:53 AM:   @netlify/build 2.0.25
10:29:53 AM: ​
10:29:53 AM: ❯ Flags
10:29:53 AM:   deployId: 5f018f68af55530007b8eed6
10:29:53 AM:   mode: buildbot
10:29:53 AM: ​
10:29:53 AM: ❯ Current directory
10:29:53 AM:   /opt/build/repo
10:29:53 AM: ​
10:29:53 AM: ❯ Config file
10:29:53 AM:   No config file was defined: using default values.
10:29:53 AM: ​
10:29:53 AM: ❯ Context
10:29:53 AM:   production
10:29:53 AM: ​
10:29:53 AM: ┌───────────────────────────────────┐
10:29:53 AM: │ 1. Build command from Netlify app │
10:29:53 AM: └───────────────────────────────────┘
10:29:53 AM: ​
10:29:53 AM: $ hugo
10:29:54 AM: Building sites … ERROR 2020/07/05 08:29:54 render of "page" failed: 

execute of template failed: template: posts/single.html:4:5: executing “main” at
<partial "taxonomies…>:
error calling partial: “/opt/build/repo/layouts/partials/taxonomies.html:3:14”:
execute of template failed: template: partials/taxonomies.html:3:14:
executing “partials/taxonomies.html” at <.GetTerms>:
can’t evaluate field GetTerms in type *hugolib.PageOutputERROR 2020/07/05 08:29:54 render of “page” failed: execute of template failed: template: posts/single.html:4:5: executing “main” at <partial "taxonomies…>:
error calling partial: “/opt/build/repo/layouts/partials/taxonomies.html:3:14”:
execute of template failed: template: partials/taxonomies.html:3:14:
executing “partials/taxonomies.html” at <.GetTerms>:
can’t evaluate field GetTerms in type *hugolib.PageOutputTotal in 14 ms
10:29:54 AM: Error: Error building site: failed to render pages: render of “page” failed: execute of template failed: template: posts/single.html:4:5: executing “main” at <partial "taxonomies…>: error calling partial: “/opt/build/repo/layouts/partials/taxonomies.html:3:14”: execute of template failed: template: partials/taxonomies.html:3:14: executing “partials/taxonomies.html” at <.GetTerms>: can’t evaluate field GetTerms in type *hugolib.PageOutput​
10:29:54 AM: ┌─────────────────────────────┐
10:29:54 AM: │ “build.command” failed │
10:29:54 AM: └─────────────────────────────┘
10:29:54 AM: ​
10:29:54 AM: Error message
10:29:54 AM: Command failed with exit code 255: hugo
10:29:54 AM: ​
10:29:54 AM: Error location
10:29:54 AM: In Build command from Netlify app:
10:29:54 AM: hugo
10:29:54 AM: ​
10:29:54 AM: Resolved config
10:29:54 AM: build:
10:29:54 AM: command: hugo
10:29:54 AM: commandOrigin: ui
10:29:54 AM: publish: /opt/build/repo/public
10:29:54 AM: Caching artifacts
10:29:54 AM: Started saving build plugins
10:29:54 AM: Finished saving build plugins
10:29:54 AM: Started saving pip cache
10:29:54 AM: Finished saving pip cache
10:29:54 AM: Started saving emacs cask dependencies
10:29:54 AM: Finished saving emacs cask dependencies
10:29:54 AM: Started saving maven dependencies
10:29:54 AM: Finished saving maven dependencies
10:29:54 AM: Started saving boot dependencies
10:29:54 AM: Finished saving boot dependencies
10:29:54 AM: Started saving go dependencies
10:29:56 AM: Finished saving go dependencies
10:29:56 AM: Error running command: Build script returned non-zero exit code: 1
10:29:56 AM: Failing build: Failed to build site
10:29:56 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
10:29:56 AM: Finished processing build request in 25.547474993s

[SOLVED]
I had to set the environment variable HUGO_VERSION to 0.73.0.

1 Like