Hugo server command serving wrong page?

I recently started playing around with hugo 0.46 on Windows 10 and I ran into an issue. Basically, when I run “hugo server” I get the wrong site served to me.

I started by creating a new site. I downloaded the dopetrope theme from https://github.com/curttimson/hugo-theme-dopetrope and played around with colors and layouts.

After a while I figured I got the hang of it and wanted to move to a clean slate. So I created a new site in a different folder and set up the same dopetrope theme without modifying it (yet). However, to my surprise, when I run “hugo server” against my newly set up site I still get the first site (with the modified theme) when I go to http://localhost:1313/.

If I open up the css file in the browser I can see my modifications there so I am sure what I am getting is the first site. I even went as far as renaming the folder where the first site’s files are but I am still getting it served to me. I also tried deleting the hugo cache folder and running the server command with --ignoreCache and --disableFastRender but it does not matter.

Finally, I looked at hugo.exe in ProcessMonitor to see if it is reading files from somewhere outside of the newly created site’s folder but no, it only reads from there. What’s going on? Where does it pull the old files from? If I shut down the server I don’t get any site at all, so there aren’t multiple servers running either. And besides, it’s been a few days since I have knowingly served that old site.

Have I gravely misundestood something or what’s going on here?

Thanks!

Hmm, seems this could be a classic case of the browser caching the data. Do people usually use a browser extension to force the browser to bypass the cache, when doing active development with hugo or what’s the best way to get around this?

What browser do You use? I’m using Windows 10 and using Firefox as default browser. The Firefox works fine when I run the Hugo but I have the same experience when using Chrome (cachce problem)

Have you try private mode?

Yeah, I am on Chrome here so probably the same problem. I installed an extension called “Cache Killer” which seems to solve the issue for the time being. Funny that no tutorial on Hugo, text or video, mentioned this as a possible issue. But yeah, seems to work fine as long as I turn on the extension while developing. Another possibility is to enable the Chrome developer mode (eg. by pressing F12) and disabling the cache from there, but it turns it back on if the dev mode is disabled.

I use Chrome in developer mode (there is a checkbox there to turn off cache, default is off).

One alternative, but I find it somehow slow things down a little too much is:

hugo server  --noHTTPCache
1 Like

Two reasons you will see the wrong site in dev:

  1. You have a Hugo server already running and the server command opens on a new port.
  2. You were crating a PWA and you need to clear service worker cache.

Sounds like you’re experiencing #2.

I don’t know what a PWA is, but as I wrote I just created a new HUGO site and installed a theme. Also, as I already wrote I did not have more than one server running.

However, the problem really seemed to be the browser cache. I was just surprised that no tutorials, official or otherwise, mentioned this at all. Most of them contained info about the auto-reload mechanism and the fact that the server updates resources on the fly, but nothing about the browser cache making things difficult. I have verified this on another machine, again with Chrome, and I get the same issues there. Luckily the extension makes it easy to disable the cache.

EDIT: Oh, and I could have sworn I tried with --noHTTPCache and it did not help, but now I am not so sure anymore…

PWA is a Progressive Web App. The theme you installed, which one was it (the one which kept showing up)?

I appreciate the help, but I consider this solved for now.

The theme is dopetrope. It’s right there in my original text, url and everything.

Glad you were able to find a solution. Dopetrope doesn’t use Service Worker caching so it sounds like you may be having some issues with your browser attempting to cache files. For that you don’t need an extension. Just click the ‘Disable cache’ feature in your browsers dev tools.