{"id":"265885dc4a5b70b6","repo":"gohugoio/hugo","slug":"logged-d-error-s","errorCode":null,"errorMessage":"logged %d error(s)","messagePattern":"logged (.+?) error\\(s\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/hugo_sites_build.go","lineNumber":247,"sourceCode":"\n\t\th.Log.Printf(\"\\nTemplate Metrics:\\n\\n\")\n\t\th.Log.Println(b.String())\n\t}\n\n\th.StopErrorCollector()\n\n\terr := <-errs\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := h.fatalErrorHandler.getErr(); err != nil {\n\t\treturn err\n\t}\n\n\terrorCount := h.Log.LoggCount(logg.LevelError) + loggers.Log().LoggCount(logg.LevelError)\n\tif errorCount > 0 {\n\t\treturn fmt.Errorf(\"logged %d error(s)\", errorCount)\n\t}\n\n\treturn nil\n}\n\n// Build lifecycle methods below.\n// The order listed matches the order of execution.\n\nfunc (h *HugoSites) initSites() error {\n\th.reset()\n\treturn nil\n}\n\nfunc (h *HugoSites) initRebuild(config *BuildCfg) error {\n\tif !h.Configs.Base.Internal.Watch {\n\t\treturn errors.New(\"rebuild called when not in watch mode\")\n\t}\n","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/hugo_sites_build.go#L229-L265","documentation":"At the end of a build, Hugo checks the logger's error counter; if any ERROR-level messages were emitted during the build (by templates calling errorf, render hooks, deprecations promoted to errors, etc.), the build is failed with this summary error even though no single step returned a hard error. It converts logged errors into a non-zero exit.","triggerScenarios":"Build completes but h.Log.LoggCount(logg.LevelError) > 0: templates invoking `errorf`, ERROR-level deprecation warnings (features past their deprecation window), warnings escalated via `--logLevel` config, or REF_NOT_FOUND-style errors when `refLinksErrorLevel = 'ERROR'`.","commonSituations":"Upgrading Hugo so an old WARN deprecation graduated to ERROR; broken `ref`/`relref` links with strict ref error level; a theme's errorf guard firing (e.g. missing required params); CI failing with this message while the actual errors are earlier in the log.","solutions":["Scroll up in the build output — the real ERROR lines precede this summary; fix each of them.","For deprecation errors, update the deprecated config/template usage named in the log.","If an error is expected and tolerable, use `ignoreLogs` with the error's id (shown in the log) in site config.","For ref errors, fix broken links or lower `refLinksErrorLevel` to 'WARNING' as a stopgap."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isLoggedErrors(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"logged\") && strings.Contains(err.Error(), \"error(s)\")\n}","tryCatchPattern":"if err := h.Build(cfg); err != nil {\n    if isLoggedErrors(err) {\n        // aggregate marker: real causes were already written to the logger\n        // read the captured log output for the per-page errors\n    }\n    return err\n}","preventionTips":["Attach a capturing logger to the build so the individual errors behind the count are retrievable","Treat this as an aggregate signal — fix the first logged error and rebuild; later ones are often cascades","Don't set ignoreErrors/ignoreLogs broadly; suppressed warnings escalate into this opaque failure"],"tags":["hugo","build","logging","deprecation","ci"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}