Hugo

Live reload broken

Continuing the discussion from Live reload not working again, how can I fix?:

Unfortunately I have the same problem and live reloading on my machine suddenly has stopped from working. I can’t figure out why.

I’m on

Hugo Static Site Generator v0.57.2/extended darwin/amd64 BuildDate: unknown

These are the messages I get on starting Hugo:

Total in 248 ms
Watching for changes in /Users/cl/c11h-website-raw/{archetypes,assets,content,data,i18n,layouts,static}
Watching for config changes in /Users/cl/c11h-website-raw/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Upon changes Hugo reports success:

Change detected, rebuilding site.
2019-09-04 17:58:23.463 +0200
Source changed "/Users/cl/c11h-website-raw/content/home/hero.md": WRITE
WARN 2019/09/04 17:58:23 Page's .Hugo is deprecated and will be removed in a future release. Use the global hugo function.
WARN 2019/09/04 17:58:23 Page's .LanguagePrefix is deprecated and will be removed in a future release. Use .Site.LanguagePrefix.
Total in 23 ms

But nothing happens in the browser :frowning_face: Changes only show up if I restart Hugo and manually refresh the browser.

This is what I’ve tried so far:

  • manually refresh the browser after each change
  • hugo server --buildDrafts
  • hugo server --watch --buildDrafts
  • hugo server --disableFastRender
  • hugo server --buildDrafts --disableFastRender
  • tried (several) other browser(s) (Firefox is my default)
  • cleared the browser cache
  • checked the console for errors
  • restarted my machine

Nothing helped. I have no clue what to do or how to debug. Thanks in advance for your help.

A guess from me would be that Hugo fails to inject the LiveReload script. Do you have a HTML body tag in your output?

Just a note from the hair-splitter that I am: In HTML5 you do not need to have html, head or body tags. If you make the live reload dependant on these tags we might get some more of these issues.

Thank you. Yes I have. This is the relevant part of the output:

<script data-no-instant>document.write('<script src="/livereload.js?port=1313&mindelay=10&v=2"></' + 'script>')</script>
</body>

I can also report that in the meantime I checked out previous commits just to make sure it isn’t a content and/or code related issue. But it doesn’t make a difference.

The crazy thing is: it used to work and then stopped.

Weird.

Together with our OPS-Team we investigated this issue further and I’m sorry to report back that this seems to be a bug in newer versions of Hugo. Here is, what we found out:

  • changes in templates (“template changed”) are reflected in the browser and in the source code
  • changes in md files (“source changed”) are not
  • the browser reload is triggered in both cases, so its not livereload.js related

After this finding we unistalled Hugo completely and installed several releases locally. This is the outcome:

  • v0.58.0 => not working
  • v0.57.0 => not working
  • v0.56.3 => not working
  • v0.55.6 => not working
  • v0.55.4 => working

So this must have been introduced in version 0.55.6. I’ll file a bug report accordingly.

I would like to let you have a look in our Github Repo but we are in company environment and making the repo public is not compliant.

thanks

Could you also test 0.55.5?

Tested. Working.

Solved: https://github.com/gohugoio/hugo/issues/6308

2 Likes

Thank you for helping to solve this @totoff!