I am using plain CSS with Hugo stored in the assets folder so, assets/css. In the root of css I have a file called site.css which includes a couple of @import declarations, for example:
Files in the assets directory are global resources, and they are not published to public unless they are (a) captured as a resource (using resources.Get, resources.GetMatch, etc.), and (b) the object of the .Permalink, .RelPermalink, or .Publish methods.
Your site.css file meets both of those requirements, so it is published to the public directory.
You have two choices:
Option 1 (preferred)
CSS is valid SCSS, so can you bundle the files together.
First remove the extension from the import statements:
Thanks so much, @jmooring, I thought that might be the case. Would running the site.css through PostCSS change this at all? I was thinking of doing that to have it run autoprefixer on my CSS. The one thing I am not super keen about is having to install postcss and any plugins globally.
I see you can (must) have them managed via package.json if you are using the snap version of Hugo. I have not dug anymore into what exactly the snap version is but, is there a way to have PostCSS locally installed without the snap version?
I partially ask because how would it work when deploying to Netlify? I guess you can use a pre-build where you install all the things globally. Anyhow, I do not want to completely derail this into a completely different topic. - Thanks again for the help.
Thank so much. I was basing my comment on the docs here:
Hugo Pipe’s PostCSS requires the postcss-cli JavaScript package to be installed in the environment (npm install -g postcss postcss-cli ) along with any PostCSS plugin(s) used (e.g., npm install -g autoprefixer ).
If you are using the Hugo Snap package, PostCSS and plugin(s) need to be installed locally within your Hugo site directory, e.g., npm install postcss-cli without the -g flag.
Great to know one is not locked into installing it globally without the snap package.