{"id":"929a7162690a8d28","repo":"gohugoio/hugo","slug":"the-configured-defaultcontentversion-q-does-not-e","errorCode":null,"errorMessage":"the configured defaultContentVersion %q does not exist","messagePattern":"the configured defaultContentVersion %q does not exist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/versions/versions.go","lineNumber":200,"sourceCode":"\n\t// Sort by weight if set, then semver descending.\n\tsort.SliceStable(r.Sorted, func(i, j int) bool {\n\t\tri, rj := r.Sorted[i], r.Sorted[j]\n\t\tif ri.Weight == rj.Weight {\n\t\t\treturn ri.parsedVersion.Compare(rj.parsedVersion) < 0\n\t\t}\n\t\tif rj.Weight == 0 {\n\t\t\treturn true\n\t\t}\n\t\tif ri.Weight == 0 {\n\t\t\treturn false\n\t\t}\n\t\treturn ri.Weight < rj.Weight\n\t})\n\n\tif !defaultSeen {\n\t\tif defaultContentVersionProvided {\n\t\t\treturn fmt.Errorf(\"the configured defaultContentVersion %q does not exist\", defaultContentVersion)\n\t\t}\n\t\t// If no default version is set, we set the first one.\n\t\tfirst := r.Sorted[0]\n\t\tfirst.Default = true\n\t\tr.versionConfigs[first.Name] = first.VersionConfig\n\t\tr.Sorted[0] = first\n\t}\n\n\treturn nil\n}\n\nfunc (r VersionsInternal) Has(version string) bool {\n\t_, found := r.versionConfigs[version]\n\treturn found\n}\n\nfunc DecodeConfig(defaultContentVersion string, m map[string]any) (*config.ConfigNamespace[map[string]VersionConfig, VersionsInternal], error) {\n\treturn config.DecodeNamespace[map[string]VersionConfig](m, func(in any) (VersionsInternal, any, error) {","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/versions/versions.go#L182-L218","documentation":"Raised at the end of versions init (hugolib/versions/versions.go:200) when defaultContentVersion was explicitly set in config but no key in the versions map matches it. If defaultContentVersion is unset Hugo silently picks the first sorted version instead — the error only fires for an explicit, dangling reference.","triggerScenarios":"Config with defaultContentVersion = \"vX\" where the versions map has no \"vX\" entry — the comparison is exact, so a case or spelling mismatch (\"V2\" vs \"v2\") also triggers it.","commonSituations":"Renaming or deleting a version in the versions block without updating defaultContentVersion, typos, or environment-specific config overlays that override the versions map but keep an old default.","solutions":["Make defaultContentVersion exactly match one of the keys in your versions map (case-sensitive).","Add the missing version entry to the versions map if it was removed by mistake.","Or delete defaultContentVersion to let Hugo pick the first version by weight/semver order.","Run `hugo config` to see the merged versions map if overlays are involved."],"exampleFix":"# before\ndefaultContentVersion = \"v3\"\n[versions.v1]\n[versions.v2]\n# after\ndefaultContentVersion = \"v2\"\n[versions.v1]\n[versions.v2]","handlingStrategy":"validation","validationCode":"names := map[string]bool{}\nfor _, v := range versionsConfig { names[v.Name] = true }\nif d := cfg.DefaultContentVersion; d != \"\" && !names[d] {\n    return fmt.Errorf(\"defaultContentVersion %q not among defined versions\", d)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check defaultContentVersion against the declared versions list whenever either changes","Update defaultContentVersion in the same commit that renames or removes a version","Add a config consistency check in CI that fails on dangling defaultContentVersion references"],"tags":["hugo","config","versions","default-content-version"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}