Hugo Error on Netlify - Function "Now" Not Defined

hugo, netlify

I encountered the error below while trying to deploy this blog using Netlify.

template.go:477: template: theme/partials/sidebar-content.html:28: function "now" not defined
.....
Error running command: Build script returned non-zero exit code: 255

The function “now” is indeed a valid function in Hugo, but it was recently introduced. Judging from the Docker build image script of Hugo on Netlify, the latest available version of Hugo used there is 0.19.

The fix is to go to your Netlify’s Environment Variables setting (Build and Deploy -> Build Environment Variables) and set HUGO_VERSION to 0.20 in your environment.

More information on setting Hugo version on Netfliy can be found on this Netflify’s official blogpost.