I am building a website using the sam theme, which use hugo pipes and sass files.
When I make a modification to a sass file, like for example changing the background color, it is taken into account when doing locally
hugo serve from the command line.
I am using netlify, and I manage to build the site without error, but the modifications to the sass files are not taken into account (ie the appearance remains like the default)
I have noticed that the .content file under resources/_gen/assets/sass/sass/ has the new color, but that the css file under public/css/ has the old color, meaning that for some reason the css file under public doesn’t include the modifications.
I thought it might have something to do with the links in the theme’s css.html, but I am not sure what to change.
I am still new to website building, css and hugo, and figuring it out. Any help is greatly appreciated.
I haven’t dug everywhere, but looking at the partial you linked to, I don’t think the sam theme will use
static/css/style.css, but instead uses the stylesheet built by hugo pipes (the one under
I wonder if the problem you’ve got with netlify is to do with git submodules? How have you loaded the theme (i.e. is it a submodule)? How did you modify the SASS file?
If you’re using a submodule, you should be modifying the theme itself, but instead, override elements you want to change. So for example, if you want to make changes to the stylesheet, make a copy of the file in
/themes/hugo-theme-sam/assets/sass and put them in
/assets/sass. Then make modifications to your version of the stylesheet.
Thanks for your reply.
Yes, netlify requires to add hugo themes as a submodule, so that’s what I did.
Up to now, I have modified the sass files directly in the theme. I have followed your advice to copy assets/ to the root and modify the files there, but it didn’t change the result in the netlify build.
Also, when I run
hugo locally from the command line, the css file created under public/ doesn’t contain the new color. I am not sure if that was clear in my first post. So even locally, the css created by the hugo build is different than what is shown when I run
hugo serve, and I’m not sure why.
- If you’ve been messing with files stored in a submodule, you might have caused some confusion in git…so it’s worth looking into that.
- When you run
hugoand look at your
/publicdirectory, which css file are you referring to? The one named
css/style.cssor the one with fingerprinting (i.e.
- Have you read the updated README for the theme? The author updated it yesterday in response to a similar question.
- Can you share a link to your git repository?
- I don’t get any git errors. But maybe I need to redo the process of getting the theme.
- I refer to the minified css file with fingerprinting.
- I have seen the question but I don’t think it’s related to my problem.
I am sure there is a very simple solution to my issue, where my file structure is wrong or the links in the css.html don’t work. But I am not yet able to see it because I am very new to all of this.
Thank you for your time.
- The repo is here.
Thanks for sharing your git repository.
Two things I’ve noticed:
I’ve cloned your site now, and I can see the CSS changes you’ve made from the default (background is white, not dark grey).
So it seems the problem is with the build on Netlify. After you’ve made the changes suggested above (i.e. making sure the theme is in a submodule) can you post the log from the last Netlify build?
You are right, the theme was not installed as a submodule. I had first installed it using git clone, and hadn’t deleted it before doing git submodule, so I guess it didn’t work.
Once installed as a submodule, I get a /sass/ folder at root level which I can modify. When I do so, this breaks the netlify build, which until then worked properly. The reason is that I need to install postcss-cli and autoprefixer, as shown in the following message in the netlify log
ERROR 2020/01/15 11:47:44 error: failed to transform resource: POSTCSS: failed to transform “css/main.css” (text/css): PostCSS not found; install with “npm install postcss-cli”. See https://gohugo.io/hugo-pipes/postcss/
I followed the instructions and installed them using
However I am not sure how this will impact the netlify build. Do I need to copy a particular file to my starting folder and push it to the repo to get postcss to work?
I’m not sure as I’ve not needed to use postcss with any of my sites.
However, this came up from searching the hugo forums
So I think as long as you commit your
resources folder, netlify doesn’t need to use postcss.
If the problem is with a netlify deploy, you may find more help in their community https://community.netlify.com/search?q=postcss
I agree that now that I have identified the issue, I can ask on the netlify forum for more info on the postcss workflow.
Thank you so much for your help!