I am having a real struggle with Hugo assets and images.
For example, say I import a library with the following directory structure:
- library
-- scss
-- main.scss
-- img
-- bg.png
-- js
I place this whole thing in to my /assets directory and bring main.scss into the head using resources.Get and toCSS. Lovely!
But, then I notice that there are references in main.scss to the img directory eg:
.element { background-image: url('./img/bg.png');
I get a 404 on the background image because it has not copied over when the site is generated (because no file references it directly with .Permalink or .RelPermalink).
Now I can’t just move the /img directory to /static because:
- It would break the directory structure of the imported library
- Who knows how many references to /img are strewn throughout main.scss (a typical library will have dozens of scss files) so I’d have to go through and update every reference.
This just feels really silly. Referencing an image using a relative link from a css/scss file is extremely common - I think Hugo’s asset pipeline should support it.
Note: All of the above is assuming I’m not being a huge dummy and missing an obvious way to fix this with existing functionality