From: Joe Mooring Date: Fri, 13 Mar 2026 01:31:12 +0000 (-0700) Subject: hugolib: Fix server no watch X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=59e0446fe5c7cb8080a3f0736c4453110b89f732;p=brevno-suite%2Fhugo hugolib: Fix server no watch Closes #14615 Co-authored-by: Claude Sonnet 4.6 --- diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index 17f7c492e..84b070d13 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -61,7 +61,7 @@ import ( // Build builds all sites. If filesystem events are provided, // this is considered to be a potential partial rebuild. func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error { - if h.isRebuild() && !h.Conf.Watching() { + if h.isRebuild() && !h.Conf.Watching() && !h.Conf.Running() { return errors.New("Build called multiple times when not in watch or server mode (typically with hugolib.Test(t, files).Build(); Build() is already called once by Test)") } if !h.isRebuild() && terminal.PrintANSIColors(os.Stdout) { diff --git a/testscripts/server/server__watch_false.txt b/testscripts/server/server__watch_false.txt new file mode 100644 index 000000000..2c6fe0b71 --- /dev/null +++ b/testscripts/server/server__watch_false.txt @@ -0,0 +1,17 @@ +# Test the hugo server command with watch disabled. + +hugo server --watch=false & + +waitServer + +httpget $HUGOTEST_BASEURL_0 'HOME' +httpget $HUGOTEST_BASEURL_0 'HOME' + +stopServer +! stderr . + +-- hugo.toml -- +baseURL = 'https://example.org/' +disableKinds = ['page','rss','section','sitemap','taxonomy','term'] +-- layouts/home.html -- +HOME