Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hugo rebuild loop when using Visual Studio Code

When I open a Hugo project in Visual Studio Code and run hugo server, the Hugo server goes into a constant rebuild cycle, even though I'm not making any changes to the content. For example:

Change detected, rebuilding site.
2022-02-01 10:35:45.916 +0000
Rebuilt in 856 ms

Change detected, rebuilding site.
2022-02-01 10:35:52.415 +0000
Rebuilt in 861 ms

If I'm viewing a page in a web browser, this in turn triggers a page reload every few seconds.

If VSCode is closed this is not an issue; similarly, I don't get this if I edit in TextMate.

I'm assuming that VSCode must be modifying some files, and that the Hugo server is detecting those changes.

How can I stop this? For example, is there a Hugo config element that I could change to ignore changes to certain files that are only touched by VSCode?

For additional information such as versions, this is the output from starting Hugo:

Start building sites … 
hugo v0.89.4+extended darwin/amd64 BuildDate=unknown

                   | EN  
-------------------+-----
  Pages            | 43  
  Paginator pages  |  0  
  Non-page files   |  4  
  Static files     | 43  
  Processed images | 10  
  Aliases          |  3  
  Sitemaps         |  1  
  Cleaned          |  0  

Built in 688 ms
Watching for changes in /Users/stevie/dev/gowork/src/github.com/stephen-masters/hugo-test/{assets,content,layouts,package.json,themes}
Watching for config changes in /Users/stevie/dev/gowork/src/github.com/stephen-masters/hugo-test/config.toml, /Users/stevie/dev/gowork/src/github.com/stephen-masters/hugo-test/themes/docsy/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode.
like image 500
Steve Avatar asked Feb 21 '26 02:02

Steve


1 Answers

My solution is to disable git.autorefresh in settings, and that immediately solves this problem. Perhaps it is related to some changes happened in the .git directory.

like image 129
Hakula Avatar answered Feb 22 '26 20:02

Hakula



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!