Local server not refreshing CSS or shortcodes

Hello everyone, I’ve been working on my site and I’ve been having some issues with the local server. Most of the time, i can make changes and iterations and the site will auto-update just fine, in both Firefox (my primary dev browser) and Safari (my primary personal browser).

my Hugo Version

hugo v0.135.0+extended darwin/arm64 BuildDate=2024-09-27T13:17:08Z VendorInfo=brew

My main issue that I would love to address is related to my stylesheet. I have style.css in my theme folder, cbtheme2/static/styles/style.css

When I make a change to the style sheet, it will auto refresh, but if I change pages or make another update, it will revert the changes to when I first opened the stylesheet for editing. I then have to either:

  1. kill the server, start the server and manually refresh the page for changes to populate
    or
  2. Make a small change to the css file such as changing a value (5px to 15px), save ,then change back (15px to 5px). Then manually refresh.

Its been very frustrating, its adding a lot of steps and time to the development process. I’ve done a few searches on this and haven’t found any solutions.

Another issue, which may be related; I was editing a shortcode that stored in /layouts/shortcodes/. When an update / edit is saved, i will have to kill and restart the server for the changes to populate. I have sinced moved the shortcode into my theme’s shortcode folder and it works as expected.

Any ideas? I appreciate the help! Let me know if there is anything I can provide that could help troubleshoot this, that is if I’m not missing something simple.

1 Like

I cannot reproduce the problem as described with v0.135.0-f30603c47f5205e30ef83c70419f57d7eb7175ab+extended linux/amd64.

Here’s the test site:

git clone --single-branch -b hugo-forum-topic-51802 https://github.com/jmooring/hugo-testing hugo-forum-topic-51802
cd hugo-forum-topic-51802
hugo server

Then edit either/both of these:

themes/foo/static/styles/styles.css
layouts/shortcodes/foo.html

So there’s probably something about your site that is different.

Hmm. That’s so weird. I had wondered if it had anything to do with the shortcode I was writing so I stripped it of all hugo code and put text in as placeholders and its still behaving the same way.

What could I do to help aid in troubleshooting this? It really does make development a pain.

Can you reproduce the problem on your system using the test repository from my previous reply?

1 Like

Okay I’ve cloned the repo and have tried the following (spoiler: i was not able to replicate the problem either):

  1. made small changes to both the CSS and the foo.html
  2. copied over my entire stylesheet from my custom theme
  3. created a datafile
  4. called information from the datafile (which is the thing I was working on)
  5. made changes to everything

All with perfect functionality. I was hoping that it was something in my CSS that was causing this.

I’m not using github at all, any other way to share my code so you can see the problem?

You should be using GitHub, GitLab, or similar.

any other way to share my code

Search Google for file sharing services.

Thanks - i’ve uploaded my code to github after some lenghty updates and changes. It still does not auto-refresh with any kind of certain frequency, but i fear that i’m so far away from that original problem that I’m not even sure what I’m troubleshooting anymore.

The structure of your Git repository is unexpected. It looks like you’re uploading files instead of creating a local repository then pushing to GitHub. It would be in your long term interest to learn how to use Git.

Regardless, I am unable to reproduce the problems you describe when I test with the files in your repository.

Hi!

I have exactly the same issues, hugo server not refreshing pages when I edit custom CSS or shortcodes.

$ hugo  version
hugo v0.135.0+extended linux/amd64 BuildDate=unknown

I will try the demo repo @jmooring provided.

Cheers,
Ekki

1 Like