The base path for 'resource.Get'

Hi,

many thanks to @bep and others for making new features in Hugo 0.43 that are so nice for processing Web resources.

I tried out {{ $styles := resources.Get "..." ... }} as in documentation and ‘https://github.com/bep/hugo-sass-test’. It seems that resources.Get will look into paths starting with project_root/assets ? Can I change this value, i.e. the base path where resources.Get will look up?

Thanks.
Huy

Try assetDir in your project config file.
The doc is coming but in the mean time, the best resource so far is here as mentionned in the Hugo news release: https://github.com/gohugoio/hugo/commit/dea71670c059ab4d5a42bd22503f18c087dd22d4

1 Like

resources.Get also looks in the assets directory of your theme (so themes/mytheme/assets/). That way you can keep your asset files together with the rest of the theme.

I don’t know of a way to have resources.Get look elsewhere.

It might not be possible, since I recall a GitHub discussion about naming where ‘assets’ was decided as the go-to name for resources. (Can’t find that issue at this time.)

1 Like

Currently no.

I had some plans on allowing more (/static, /content), but I got into all sorts of trouble with the live-reloading bit, so that had to go.

4 Likes

Thanks all for your quick and cordial replies. I was just trying to minify my existing CSSs using Hugo minify instead of using external workflows (e.g. gulp, webpack) – looking forward to get rid of these tools for just post-processing / minifying. Thus, I specified resources.Get "/css/...". So it seems the viable solution for now is to move the to-be-processed CSSs to assets folder.

1 Like

Just an added note: You can create a symbolic link from /assets … somewhere.

1 Like

Hi, thanks for the great job for pipes!

The assetDir = "static" is working fine and I’m able to get my resources from my static/css folder.
But it’s still looking for the default assets folder in the theme’s directory.

Any way to fix this?

Thank you

But in the soon to come next Hugo, you can configure custom “file mounts” (and we have greatly improved symlink support, too, if that is your cup of tea).

2 Likes

A note here: You can now very simply mount any folder into /assets and get to it with Get.

1 Like