Question

Hugo deployment error

Posted December 28, 2021 113 views
DigitalOcean App PlatformBuilding on DigitalOcean

I’m quite new to this so I apologize if this is not the correct place/way to ask. I have a Hugo site that I’ve been building and I’ve created a GitHub repository for it. I’ve linked them both successfully but the site continually gets the same error when building with hugo -d public on DigitalOcean. When the site is on my system, I can build it with the same command without error perfectly fine, and hugo serve -e production also works without error. The error from Digital Ocean is posted below and I cannot figure out it’s cause. It says that it is coming from parsing HTML files within the theme, but I have not changed the theme whatsoever (it is straight from it’s repo.)

[2021-12-28 07:04:18] => Building app
[2021-12-28 07:04:18] 
[2021-12-28 07:04:18] Ensuring Hugo is installed
[2021-12-28 07:04:18] Hugo Extended v0.82.0 requested
[2021-12-28 07:04:18] Installing Hugo Extended v0.82.0
[2021-12-28 07:04:18]   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
[2021-12-28 07:04:18]                                  Dload  Upload   Total   Spent    Left  Speed
100   676  100   676    0     0   3058      0 --:--:-- --:--:-- --:--:--  3045
[2021-12-28 07:04:19] LICENSE
[2021-12-28 07:04:19] README.md
[2021-12-28 07:04:19] hugo
100 13.7M  100 13.7M    0     0  9109k      0  0:00:01  0:00:01 --:--:-- 12.6M
[2021-12-28 07:04:20] Running custom build command: hugo -d public
[2021-12-28 07:04:20] Total in 67 ms
[2021-12-28 07:04:20] Error: add site dependencies: load resources: loading templates: "/workspace/themes/FeelIt/layouts/partials/comment.html:24:1": parse failed: template: partials/comment.html:24: function "erroridf" not defined
[2021-12-28 07:04:20] building: exit status 255
[2021-12-28 07:04:20] ERROR: failed to build: exit status 1
[2021-12-28 07:04:21] 
[2021-12-28 07:04:21] For documentation on the buildpacks used to build your app, please see:
[2021-12-28 07:04:21]    Hugo: https://do.co/apps-buildpack-hugo
[2021-12-28 07:04:21] 
[2021-12-28 07:04:21]  ! Build failed (145)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @coopersully,

as I see from FeelIt Theme npm packages are needed. Thats why he is not building. The packages are missing.

It seems to be that npm is not available in this Hugo images, so it would not be a fix to copy package.json over from the theme and alter the build command to install packages first (npm -i).

I have a similiar issue with a theme that has npm package dependencies.

For this reason i will give docker a try as mentioned here: https://docs.digitalocean.com/products/app-platform/languages-frameworks/hugo/#go_the-ways-app-platform-works

  • Hello!

    If Node.js packages are required by your theme it is indeed not supported currently. You can either build your theme locally and commit the results to git so that you would only need to run the Hugo build on App Platform, or switch to using a Dockerfile which would give you complete control over the build environment.

    I would recommend the first option as it’s simpler to maintain. You might need to manually copy the theme files into your repo instead of using a submodule.

    If you would like to proceed with the second option, you can refer to another community member’s repo with an example Dockerfile: https://github.com/digitalocean/sample-hugo/issues/7#issuecomment-942891895