Hugo

Caching issues with hugo server

I’m having major caching issues with hugo server, and the CSS not being rebuilt.

I’m currently using this command, which, when run again correctly displays the latest CSS. But only after explictily being run:

hugo server --disableFastRender --environment=dev --bind "0.0.0.0"

And I get this output:

                   |  EN   
+------------------+------+
  Pages            | 1038  
  Paginator pages  |   17  
  Non-page files   |  943  
  Static files     |   44  
  Processed images |    0  
  Aliases          |   69  
  Sitemaps         |    1  
  Cleaned          |    0  

Total in 643 ms
Watching for changes in /myPATH/{archetypes,assets,content,data,i18n,layouts,static}
Watching for config changes in /myPATH/config.toml
Environment: "dev"
Serving pages from memory
Web Server is available at //localhost:1313/ (bind address 0.0.0.0)
Press Ctrl+C to stop

Hard refreshes don’t help, I check the public folder and the CSS is not being written with the latest Sass.

I am using this Hugo Pipes setup for my Sass:

{{ if .Site.IsServer }}
{{ $cssOpts := (dict "targetPath" "css/bradbice.css" "enableSourceMap" true ) }}
{{ $styles := resources.Get "scss/bradbice.scss" | toCSS $cssOpts }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" media="screen, print">
{{ else }}
{{ $cssOpts := (dict "targetPath" "css/bradbice.css" ) }}
{{ $styles := resources.Get "scss/bradbice.scss" | toCSS $cssOpts | resources.Fingerprint "sha256" }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}" media="screen, print">
{{ end }}

Any ideas on what else I can check or try to have accurate cache refreshing (or disabled cache) with livereload?

I have not looked closely at your output, but I improved some of this in 0.57. What Hugo version are you running?

hugo version
Hugo Static Site Generator v0.57.0/extended darwin/amd64 BuildDate: unknown

I’ve had sporadic problems with LiveReload in Hugo 56.0 and above. Until a few days ago, I thought I had solved the problem by launching hugo server like this:

hugo -v server --path-warnings --ignoreCache --disableFastRender --renderToDisk --cleanDestinationDir

I thought "Aha, the trick (for my setup) is --renderToDisk" but alas, LiveReload quit working again and I’ve reverted to Hugo 55.6. I want to use the latest Hugo because I write about Hugo[*] and want to make sure what I write is correct.

I think this is related to this issue: ‘watch’ not working in vim on MacOS (0.56.*) #6139

[*] My Hugo-related writing is listed at https://www.ii.com/tag/gohugo/

Any ideas on this? Development on macOS 10.14.6 is really bad with all of these caching issues.

I’m having to restart the server or run a separate hugo command in a separate terminal tab to have it correctly render.

To be clear I’m not saying this is a Hugo issue, but I’m looking for suggestions on what I can try to fix this.

For me, this seems to be fixed in v0.58.1/extended. I hope it is for you too!