Assets and fonts

My current setup builds my JS/CSS assets using webpack into the /themes/x/assets/ folder. I then use resources.Get to include the built JS/CSS into the HTML, fingerprinting and all.

Inside the CSS I reference custom fonts that are also output (into /themes/x/assets/fonts). However, as hugo only publishes assets that are used with Permalink, the fonts never get published.

How can I get the fonts into the output? (the same goes for some images referenced in the CSS which are located in /themes/x/assets/images)

Also, side note: Why are assets published under the language folders instead of the root? This seems a bit weird for me?

Did you try to put those files in static? These will be copied into the build as they are.

Yes, but then webpack will complain that the url(...) inside the CSS files don’t point to an existing file.

To me, the best option would be to tell hugo to copy everything under /assets, whether it is referenced or not.

But if there is no way, I’ll just use the /static folder for now…

This behaviour was redone in a recent Hugo version. Now the targetPath you set when you do these SCSS transformation etc. are taken as-is.

I don’t use the SASS pipes, only fingerprinting. And that seems to always copy the resources into the language folder roots

What Hugo version?

Hugo Static Site Generator v0.45.1 windows/amd64 BuildDate: 2018-07-25T08:56:57Z

OK, read my comment above about the “recent change”.

I see - thanks! I downloaded the newest version and the assets are now in the root output folder.

1 Like