Function "resources" not defined

#1

Hugo is building and running absolutely great on my local environment, but once it’s pushed from GitHub to Netlify, the build is failing every time with the message:

Failed to add template "partials/head.html" in path "partials/head.html": template: partials/head.html:12: function "resources" not defined

The code is question looks like this:

{{- $styleHome := resources.Get "css/home.css" | minify}}
<style>{{ $styleHome.Content | safeCSS }}</style>

I’ve search on Google and the forums, and the only time I’ve ever seen this error most people say to update Hugo, but both locally and Netlify are using 0.42?

Any idea what this issue is, or why the code is only causing it on build with Netlify? Thanks!

#2

You’ll get more assistance if you share a project repo, per Requesting Help. If yours is private, consider creating a smaller one that reproduces the issue, to share. :slight_smile:

#3

How do you know the Netlify is using Hugo 0.42? Your question mark sounds like you just assumed that.

To set the version on Netlify, you need to set the HUGO_VERSION env var (see its docs). Also, I’d set the Hugo version to the latest release as of today, both locally and on Netlify (even 0.42 is a bit old).