{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/hugobuilder.go#L566-L602","documentation":"Wrapper added in fullBuild around buildSites, i.e. the main HugoSites.Build render pass. Any content, template, taxonomy, or output-format error surfaces through this wrapper, marking that the failure happened during site rendering as opposed to static-file copying.","triggerScenarios":"buildSites returning an error during a full `hugo` build: template execution errors, invalid front matter, failing shortcodes, resource/asset pipeline errors (e.g. missing SCSS transpiler), or errors raised via the errorf/erroridf template funcs.","commonSituations":"Template errors after upgrading Hugo versions (deprecated constructs removed), missing extended edition for SCSS, malformed front matter dates, or content referencing missing resources.","solutions":["Read the wrapped error chain — it usually includes file:line:col of the failing template or content file; fix that file.","Run with --logLevel debug (or -v) for more context.","If it appeared after a Hugo upgrade, check the release notes for removed/deprecated template features.","If the error mentions SCSS/Sass, install the extended edition or dart-sass."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// run a config/content sanity pass first: hugo --renderToMemory or\n// hugo config to catch config errors before a full build","typeGuard":"// Hugo build errors wrap file-error details; unwrap for position info\nvar fe herrors.FileError\nif errors.As(err, &fe) {\n    // fe has filename/line/col of the failing template or content file\n}","tryCatchPattern":"if err := b.build(); err != nil {\n    if strings.Contains(err.Error(), \"error building site\") {\n        // surface the wrapped cause (template error, content parse error) to the user\n        log.Printf(\"build failed: %v\", err)\n    }\n    return err\n}","preventionTips":["Validate templates and content in CI with a dry build before deploying","Unwrap the error chain — the root cause names the failing file and line","Keep themes/modules pinned so upstream template changes can't break builds unexpectedly"],"tags":["hugo","build","templates","content"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}