{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/versions/versions.go#L182-L218","documentation":"The site config set a defaultContentVersion, but after scanning all configured version keys none matched it (versions.go:198-200). Hugo requires defaultContentVersion to correspond to an existing version name; when it does not, initialization fails. If defaultContentVersion is left empty, Hugo picks a sensible default instead of erroring.","triggerScenarios":"Setting defaultContentVersion = \"v2.0.0\" in config while the [versions] block only defines \"v1.0.0\"; a typo in the default version name; referencing a version after deleting it from the versions config.","commonSituations":"Promoting a new default version in defaultContentVersion before adding it to [versions]; renaming a version key without updating defaultContentVersion; environment-specific config overriding versions inconsistently.","solutions":["Ensure the defaultContentVersion value exactly matches one key in the [versions] map (case-sensitive, normalized).","If unsure which versions exist, print the configured version keys and align the default.","Leave defaultContentVersion empty to let Hugo auto-select the first version."],"exampleFix":"// before\ndefaultContentVersion = \"v2.0.0\"\n[versions]\n\"v1.0.0\" = {}\n\n// after (add the version, or fix the default)\ndefaultContentVersion = \"v2.0.0\"\n[versions]\n\"v1.0.0\" = {}\n\"v2.0.0\" = { weight = 10 }","handlingStrategy":"validation","validationCode":"func validateDefaultVersion(defaultVersion string, configured map[string]VersionConfig) error {\n    if defaultVersion == \"\" {\n        return nil // Hugo auto-selects\n    }\n    if _, ok := configured[defaultVersion]; !ok {\n        return fmt.Errorf(\"the configured defaultContentVersion %q does not exist\", defaultVersion)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a version to the [versions] map before setting it as defaultContentVersion.","After renaming a version, update defaultContentVersion to match.","Leave defaultContentVersion empty to let Hugo pick the first version."],"tags":["versions","config","default","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}