I’ve built my first Hugo website and everything works fine on the local Hugo server, both in development and production. I’ve tested the site locally with netlify dev and it runs fine. I’ve checked the log with netlify build
and there aren’t errors.
However, when I try to upload the site to Netlify through GitHub I get these errors:
4:33:56 PM: ERROR 2023/01/30 16:33:56 render of “page” failed: execute of template failed: template: equipment/single.html:14:15: executing “main” at <partial “image-carousel” .>: error calling partial: execute of template failed: template: partials/image-carousel.html:12:11: executing “partials/image-carousel.html” at <partial “image” (dict “src” . “page” $ “alt” $.Title “format” “equipment”)>: error calling partial: “/opt/build/repo/layouts/partials/image.html:4:36”: execute of template failed: template: partials/image.html:4:36: executing “partials/image.html” at <.src>: wrong type for value; expected string; got *resources.resourceAdapter
4:33:56 PM: Error: Error building site: failed to render pages: render of “page” failed: “/opt/build/repo/layouts/projects/single.html:28:45”: execute of template failed: template: projects/single.html:28:45: executing “main” at : can’t evaluate field BaseName in type interface {}
4:33:56 PM: Error message
4:33:56 PM: Command failed with exit code 255: hugo --debug --minify --baseURL $DEPLOY_PRIME_URL (Search results for '"non-zero exit code: 255"' - Netlify Support Forums)
4:33:56 PM:
4:33:56 PM: Error location
4:33:56 PM: In build.command from netlify.toml:
4:33:56 PM: hugo --debug --minify --baseURL $DEPLOY_PRIME_URL
4:33:56 PM:
4:33:56 PM: Resolved config
4:33:56 PM: build:
4:33:56 PM: command: hugo --debug --minify --baseURL $DEPLOY_PRIME_URL
4:33:56 PM: commandOrigin: config
4:33:56 PM: environment:
4:33:56 PM: - NODE_ENV
4:33:56 PM: publish: /opt/build/repo/public
4:33:56 PM: publishOrigin: config
The question is why is this happening and how can I fix this?
The problem seems to be related to baseURL.
Removing “–baseURL $DEPLOY_PRIME_URL” allowed me to deploy the site with ‘netlify deploy’ from the cmd. And if I run ‘netlify deploy --prod’ I get this https://bullaki.netlify.app/.
This seems to suggest that the problem might be related to the baseURL, which in the Hugo config.yaml file is defined as
baseURL: 'https://bullaki.netlify.app/'
Now there are issues with some of the links:
- When I click on the logo (homepage) it does redirect me to http://localhost:1313/.
- When I check ‘list’ pages like this https://bullaki.netlify.app/projects/web-design/ the base URL is wrong, as it starts with localhost:1313 instead of picking the correct one.
So, I’m not sure where it’s picking up localhost:1313 from. In the Hugo ‘list’ template used to build bullaki.netlify.app/projects/ the URLs of each page in the list is defined as {{ .Permalink }}.
I would imagine a solution would be to ensure the baseURL in {{ .Permalink }} corresponds to the actual URL site on Netlify.
How can I do that? Is this likely to fix the issue?
Thanks!