]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
hugolib: Fix server no watch
authorJoe Mooring <joe.mooring@veriphor.com>
Fri, 13 Mar 2026 01:31:12 +0000 (18:31 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 13 Mar 2026 15:28:37 +0000 (16:28 +0100)
Closes #14615

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
hugolib/hugo_sites_build.go
testscripts/server/server__watch_false.txt [new file with mode: 0644]

index 17f7c492e7d9d1d67e017feb5ed5a7e058e9cd20..84b070d138df670c7f9280d949d94a8518977efe 100644 (file)
@@ -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 (file)
index 0000000..2c6fe0b
--- /dev/null
@@ -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