{"record":{"id":"bd4fe4d383e3bf5c","repo":"gohugoio/hugo","slug":"error-building-site-w","errorCode":null,"errorMessage":"error building site: %w","messagePattern":"error building site: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/hugobuilder.go","lineNumber":584,"sourceCode":"\tc.r.logger.Println(hugo.BuildVersionString())\n\tc.r.logger.Println()\n\tif terminal.IsTerminal(os.Stdout) {\n\t\tdefer func() {\n\t\t\tfmt.Print(showCursor + clearLine)\n\t\t}()\n\t}\n\n\tcopyStaticFunc := func() error {\n\t\tcnt, err := c.copyStatic()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error copying static files: %w\", err)\n\t\t}\n\t\tlangCount = cnt\n\t\treturn nil\n\t}\n\tbuildSitesFunc := func() error {\n\t\tif err := c.buildSites(noBuildLock); err != nil {\n\t\t\treturn fmt.Errorf(\"error building site: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\t// Do not copy static files and build sites in parallel if cleanDestinationDir is enabled.\n\t// This flag deletes all static resources in /public folder that are missing in /static,\n\t// and it does so at the end of copyStatic() call.\n\tvar cleanDestinationDir bool\n\tc.withConf(func(conf *commonConfig) {\n\t\tcleanDestinationDir = conf.configs.Base.CleanDestinationDir\n\t})\n\tif cleanDestinationDir {\n\t\tif err := copyStaticFunc(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := buildSitesFunc(); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/hugobuilder.go#L566-L602","documentation":"`fullBuild` runs `c.buildSites(noBuildLock)` concurrently with static copying. This wraps the core Hugo build failure, which is the catch-all for template, content, page parsing, and rendering errors produced during `hugolib.HugoSites.Build`. The wrapped error usually carries Hugo's file-error context (line/column).","triggerScenarios":"Triggered when `buildSites` returns non-nil — syntax errors in templates, invalid shortcodes, unparseable Markdown, type errors in front matter, missing layouts referenced by pages, or unsupported content features.","commonSituations":"A typo in a Go template (`{{ range .Pages }}` unclosed), an undefined partial or shortcode, invalid TOML/YAML front matter, an incompatible theme after a Hugo version upgrade, or a content file with an unsupported output format.","solutions":["Read the wrapped error for the file path and line/column (Hugo annotates file errors).","Run `hugo --verbose` or check the printed file-error context to pinpoint the failing template/content.","Comment out recently changed templates/pages to bisect the source.","Verify the theme is compatible with the installed Hugo version (`hugo version`)."],"exampleFix":"// before\n{{ range .Pages }}\n  <li>{{ .Title }}</li>\n<!-- missing {{ end }} -->\n// after\n{{ range .Pages }}\n  <li>{{ .Title }}</li>\n{{ end }}","handlingStrategy":"try-catch","validationCode":"// Use hugo in check/dry-run mode to catch template/content errors early.\n// $ hugo --renderToMemory --quiet  (non-zero exit signals a build issue)","typeGuard":"null","tryCatchPattern":"// hugolib.FileError carries file:line:col context; narrow on it.\nvar fe *herrors.FileError\nif errors.As(err, &fe) {\n  log.Printf(\"build error at %s:%d:%d: %s\", fe.Position().Filename, fe.Position().Line, fe.Position().Column, fe.Error())\n}","preventionTips":["Run `hugo` (build) before `hugo server` to catch template errors fast.","Keep themes pinned to versions compatible with your Hugo release.","Bisect new content/template changes when a build starts failing."],"tags":["hugo","build","templates","content"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}