{"record":{"id":"8b1a2245fa0dc82c","repo":"gohugoio/hugo","slug":"empty-related-config-provided","errorCode":null,"errorMessage":"empty related config provided","messagePattern":"empty related config provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"related/inverted_index.go","lineNumber":565,"sourceCode":"\treturn result, nil\n}\n\n// normalizes num to a number between 0 and 100.\nfunc norm(num, min, max int) int {\n\tif min > max {\n\t\tpanic(\"min > max\")\n\t}\n\treturn int(math.Floor((float64(num-min) / float64(max-min) * 100) + 0.5))\n}\n\n// DecodeConfig decodes a slice of map into Config.\nfunc DecodeConfig(m hmaps.Params) (Config, error) {\n\tif m == nil {\n\t\treturn Config{}, errors.New(\"no related config provided\")\n\t}\n\n\tif len(m) == 0 {\n\t\treturn Config{}, errors.New(\"empty related config provided\")\n\t}\n\n\tvar c Config\n\n\tif err := mapstructure.WeakDecode(m, &c); err != nil {\n\t\treturn c, err\n\t}\n\n\tif c.Threshold < 0 || c.Threshold > 100 {\n\t\treturn Config{}, errors.New(\"related threshold must be between 0 and 100\")\n\t}\n\n\tif c.ToLower {\n\t\tfor i := range c.Indices {\n\t\t\tc.Indices[i].ToLower = true\n\t\t}\n\t}\n\tfor i := range c.Indices {","sourceCodeStart":547,"sourceCodeEnd":583,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/related/inverted_index.go#L547-L583","documentation":"Returned by related.DecodeConfig in related/inverted_index.go:565 when the config map is non-nil but empty (len == 0). DecodeConfig expects at least threshold/indices configuration to build a meaningful related-content index.","triggerScenarios":"Providing an empty [related] table (e.g. `[related]` with no keys) in hugo.toml, or passing an empty non-nil map programmatically.","commonSituations":"Adding `[related]` to config as a placeholder but never filling it, or a config generator emitting an empty related map.","solutions":["Either remove the empty [related] table (Hugo then uses defaults) or populate it with threshold and [[related.indices]].","Add a minimal index, e.g. threshold = 80 and an [[related.indices]] entry with name and type.","Validate the config with `hugo config` to confirm the related block is non-empty."],"exampleFix":"// before\n[related]\n// after\n[related]\nthreshold = 80\n[[related.indices]]\nname = \"keywords\"\nweight = 100\ntype = \"basic\"","handlingStrategy":"validation","validationCode":"// Provide a non-empty related config or rely on defaults.\nif len(relatedCfg) == 0 { /* omit [related] to use defaults, or populate it */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Either omit [related] (defaults apply) or fill threshold + indices.","Don't ship a bare [related] header.","Validate with `hugo config`."],"tags":["related","config","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}