Error when deploying through vercel.com

I run my site locally and everthing is going fine without any error.
But when I try to deploy through Vercel with hugo --gc --minify command, I got the following error message :

Building sites … ERROR 2023/03/29 09:26:41 render of "page" failed: execute of template failed: template: _default/single.html:3:6: executing "_default/single.html" at <partial "head.html" .>: error calling partial: "/vercel/path0/themes/gallery/layouts/partials/head.html:25:41": execute of template failed: template: partials/head.html:25:41: executing "partials/head.html" at <js>: can't evaluate field Build in type string

The partial head.html is as follows:


<head>
  {{ if .IsHome -}}
    <title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
  {{- else -}}
      <title>{{ .Title }} – {{ .Site.Title }}</title>
  {{- end }}
  <link rel="canonical" href="{{ .Permalink }}">
  <link rel="icon" type="image/svg+xml" href="{{ "images/favicon.svg" | relURL }}">
  <link rel="icon" type="image/png" href="{{ "images/favicon.png" | relURL }}">
  <link rel="apple-touch-icon" sizes="180x180" href="{{ "images/apple-touch-icon.png" | relURL }}">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover">
  <meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}">
  {{ hugo.Generator }}
  {{ if .Params.private }}
    <meta name="robots" content="noindex, nofollow">
  {{ end }}
  {{ range .AlternativeOutputFormats -}}
    {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
  {{ end -}}
  {{ template "_internal/opengraph.html" . }}
  {{ $scss := resources.Get "/scss/main.scss" }}
  {{ $css := $scss | resources.ToCSS | resources.Minify | resources.Fingerprint }}
  <link rel="stylesheet" href="{{ $css.RelPermalink }}">
  {{ $js := resources.Get "js/main.js" | js.Build (dict "minify" true) | resources.Fingerprint }}
  <script src="{{ $js.RelPermalink }}" defer></script>
</head>

Any idea why the deployment failed ? Any support or directive will be much appreciated.

1 Like

The error message is incredibly odd, but I suspect there is a Hugo version issue involved here. Not sure how to set that in Vercel, but do you know which version of Hugo it’s building with there?

1 Like

It seems that It’s à very old Hugo’s version (0.58) as indicated here.
The strange thing is that I deployed other similar sites with no issues.
I don’t know how to change Hugo’s version if possible.

2 Likes

Vercel Tips This topic may help.

1 Like

Thanks a lot.
I add a vercel.json file with Hugo’s version 0.110.0 and it works perfectly

1 Like

You can also set a HUGO_VERSION environment variable.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.