{"id":"2498828ca3102218","repo":"gohugoio/hugo","slug":"permalinks-unsupported-config-type-t","errorCode":null,"errorMessage":"permalinks: unsupported config type %T","messagePattern":"permalinks: unsupported config type %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/permalinks.go","lineNumber":531,"sourceCode":"// DecodePermalinksConfig decodes the permalinks configuration.\n// It supports both the new slice-based format and the legacy map-based formats.\nfunc DecodePermalinksConfig(in any) (PermalinksConfig, error) {\n\tif in == nil {\n\t\treturn nil, nil\n\t}\n\n\tswitch v := in.(type) {\n\t// Check legacy formats first.\n\tcase map[string]any:\n\t\treturn decodePermalinksMap(v)\n\tcase hmaps.Params:\n\t\treturn decodePermalinksMap(v)\n\tdefault:\n\t\tif ms, err := hmaps.ToSliceStringMap(in); err == nil {\n\t\t\t// New slice format.\n\t\t\treturn decodePermalinksSlice(ms)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"permalinks: unsupported config type %T\", in)\n\t}\n}\n\nfunc decodePermalinksSlice(ms []map[string]any) (PermalinksConfig, error) {\n\tvar configs PermalinksConfig\n\tfor _, m := range ms {\n\t\tm = hmaps.CleanConfigStringMap(m)\n\t\tvar cfg PermalinkConfig\n\n\t\tif targetVal, ok := m[\"target\"]; ok {\n\t\t\tif err := mapstructure.WeakDecode(targetVal, &cfg.Target); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"permalinks: failed to decode target: %w\", err)\n\t\t\t}\n\t\t\tcfg.Target.Kind = strings.ToLower(cfg.Target.Kind)\n\t\t\tcfg.Target.Path = filepath.ToSlash(strings.ToLower(cfg.Target.Path))\n\t\t}\n\n\t\tif patternVal, ok := m[\"pattern\"]; ok {","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/page/permalinks.go#L513-L549","documentation":"Hugo's DecodePermalinksConfig accepts either the legacy map-based permalinks format or the newer slice-of-maps format. When the value under the `permalinks` config key is neither a map (map[string]any / Params) nor convertible to []map[string]any via hmaps.ToSliceStringMap, decoding fails with this error, reporting the Go type it received. It fires at config-load time, aborting the build.","triggerScenarios":"Setting `permalinks` in hugo.toml/yaml/json to a scalar (string, number, bool) or a plain array of strings instead of a table/map or an array of tables; e.g. `permalinks = 'posts/:year/:slug'` at the top level, or passing a wrong type when composing config programmatically.","commonSituations":"Typos flattening the config (forgetting the section key so the pattern string sits directly under permalinks); YAML indentation errors turning a mapping into a scalar or list of strings; migrating between the legacy map format and the new slice format and mixing shapes.","solutions":["Make `permalinks` a map of section→pattern, e.g. `[permalinks]\\nposts = '/:year/:month/:slug/'`.","Or use the new slice format: an array of tables each with `pattern` (and optional `target`).","Check YAML indentation so the value parses as a mapping, not a scalar or string list."],"exampleFix":"# before (hugo.toml)\npermalinks = \"/:year/:slug/\"\n\n# after\n[permalinks]\n  posts = \"/:year/:slug/\"","handlingStrategy":"type-guard","validationCode":"// site config: ensure permalinks is a map of string→string or string→map\n// permalinks:\n//   page:\n//     posts: /:year/:slug/","typeGuard":"func validPermalinksConfig(v any) bool {\n    switch m := v.(type) {\n    case map[string]any:\n        for _, val := range m {\n            switch val.(type) {\n            case string, map[string]any:\n            default:\n                return false\n            }\n        }\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Keep [permalinks] a table of section→string patterns (or kind→table), never arrays or numbers","Run `hugo config` after editing to confirm the parsed shape","Quote pattern values in TOML/YAML so they parse as strings"],"tags":["hugo","config","permalinks"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}