[SOLVED] Netlify Hugo v0.45 resource.Get images assets path

I’m in the process of trying to publish an update to a website, where I utilised the new resource.Get method to format and crop images from the assets folder (no SCSS or SASS involved). However, Netlify is failing to build the site, because of an error regarding resource.Get - it says file not found, and is looking for the assets folder in the theme directory (however, the assets file is in the root of the project, not the theme).

I’ve seen the assetDir option in the configuration, and tried setting it to /assets - which then also defaulted (on my local machine) to the theme folder. Removing the leading slash seems to work locally again for the root of the project. I had hoped setting the option would work with Netlify, but it does not seem to have helped. I also attempted to move the assets folder into the theme folder, as it seems to be where Netlify was looking. No change. Is the resource.Get functionality tied into the Hugo Pipes system in some way?

I also tried committing the resources folder as was recommended for SCSS, but that did not help.

Thanks in advance for any insights you may have.

I have 2 comments:

  1. The error message you get when the image is not found is slightly misleading – you get the error from the last place Hugo searched, which is the last theme, so to say.
  2. See https://hugoscss.netlify.com/ The sunrise (even if the image is named sunset.jpg) is fetched from /assets (in the project) – and it deploys fine to Netlify

@bep Thank you so much for the prompt reply. Your points are very useful - especially about the error message. I’m going to see if I can narrow the issue down to a single image, and if so, see what might be causing the issue.

Update: The file not found was due to the case of the extensions (the files that could not be found were “.JPG” files, and the content files had them as “.jpg”).

However, now I’ve run into a possibly related error - I use the (resources.Get .src).Resize "x320" method to resize the images for the correct locations (widths change depending on the layouts). However, Netlify doesn’t seem to process .Resize, though it does process the .Fit call I use for creating thumbnails in a gallery.

EDIT This issue was solved by re-adding the resources folder into my git repository!

1 Like