Closes #14615
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
// 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) {
--- /dev/null
+# 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