{"record":{"id":"d7deb588001f194f","repo":"gohugoio/hugo","slug":"permalinks-missing-pattern","errorCode":null,"errorMessage":"permalinks: missing pattern","messagePattern":"permalinks: missing pattern","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/permalinks.go","lineNumber":555,"sourceCode":"\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 {\n\t\t\tcfg.Pattern, ok = patternVal.(string)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"permalinks: pattern must be a string, got %T\", patternVal)\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"permalinks: missing pattern\")\n\t\t}\n\n\t\tconfigs = append(configs, cfg)\n\t}\n\n\treturn configs, nil\n}\n\nfunc decodePermalinksMap(m map[string]any) (PermalinksConfig, error) {\n\tvar configs PermalinksConfig\n\tconfig := hmaps.CleanConfigStringMap(m)\n\n\tfor k, v := range config {\n\t\tswitch v := v.(type) {\n\t\tcase string:\n\t\t\t// [permalinks]\n\t\t\t//   key = '...'\n\t\t\t// Backward compat: set for both page and term.","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/page/permalinks.go#L537-L573","documentation":"Thrown by decodePermalinksSlice when a permalink rule map has no 'pattern' key at all. Every rule in the list format must declare a pattern; this fires in the else branch when the key lookup fails.","triggerScenarios":"A [[permalinks]] entry that only sets 'target' and omits 'pattern', or a typo like 'patten' that leaves the real key absent.","commonSituations":"Hand-editing the permalinks list and forgetting the pattern line, or copy-pasting a partial rule.","solutions":["Add a 'pattern' key to every [[permalinks]] entry.","Check for typos in the key name (it must be exactly 'pattern').","Run 'hugo' and fix each rule flagged by the error."],"exampleFix":"# before\n[[permalinks]]\ntarget = { path = \"/posts/**\" }\n# after\n[[permalinks]]\ntarget = { path = \"/posts/**\" }\npattern = \"/:year/:slug/\"","handlingStrategy":"validation","validationCode":"if _, ok := m[\"pattern\"]; !ok {\n    return errors.New(\"permalinks rule missing pattern\")\n}","typeGuard":null,"tryCatchPattern":"cfg, err := page.DecodePermalinksConfig(raw)\nif err != nil { /* add the missing pattern key */ }","preventionTips":["Ensure every [[permalinks]] entry has a 'pattern' key.","Watch for typos like 'patten' or 'patterns'.","Run 'hugo' to catch missing keys at startup."],"tags":["hugo","permalinks","configuration","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}