error calling PostCSS: type <nil> not supported in Resource transformations
I’m assuming that’s because $css is actually nil, I confirmed this by printing it. I don’t have a “main.css” in my static folder as it’s coming from my theme:
ls themes/hugo-ink/static/css
dark.css main.css normalize.css
Am I supposed to do a resources.Get "themes/hugo-ink/static/css/main.css" or something else? I don’t really want to copy the whole file into my normal static directory as then every time I’m updating the theme from upstream I would have to repeat this step. I thought that by using PostCSS this is actually done after the step where Hugo copies everything into the public folder that didn’t get overwritten by my own files in the blog root.
Is there something I’m doing wrong in approaching that?
I set assetDir: "static" in my config file so that resources.Get can for example find my customCSS which is in /static/css/theme-custom.css by using the following which works:
Changing anything in themes/hugo-ink as this is a git submodule and I’d like to be able to update it from upstream easily
Copying themes/hugo-ink/static/css/main.css to /static/css/main.css so it would get picked up by resources.Get and it would work like it does for customCSS right now
Your solution would mean that I have to copy the main.css from the theme every time I’m updating it from upstream (to either /assets/ or my /static/css/ directory. I don’t want to do that.
I haven’t tested this, but this will probably work. You could create a symlink from
/path/to/your/site/assets/
which points to
/path/to/your/site/themes/hugo-ink/static/
Then whenever you update the submodule, the link should still work since the folder wouldn’t change, and you could leave the assetDir pointing to the default location.
That would probably work too, I could also just have it copy the theme css folder into my css folder but I was more hoping for a more elegant solution.
Isn’t that the main use case to strip unused CSS from the theme’s CSS (that’s maybe based on some CSS framework even) that comes with a lot of extra weight that’s maybe not used.
I believe this problem can be solved easily using Hugo Modules, but because i’m still learning this new feature, I can’t really give correct answer. and you need Golang installed for working with Hugo Modules.
But i think, we can use module.mounts (no need golang installed) to fix this. (just rough idea, not tested it yet)
change the hugo-ink git submodule location to other directory as long is not themes directory.
lets say you clone it to:
/your-hugo-project
- my-theme/
- hugo-ink
Configure module.mounts to mount hugo-ink/static into to assets