{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/page/permalinks.go#L537-L573","documentation":"Every entry in the slice-based permalinks configuration must contain a `pattern` key; decodePermalinksSlice returns this error when an entry has no `pattern` at all. An entry with only a `target` (kind/path matcher) is meaningless without a pattern to apply, so Hugo fails fast at config decode.","triggerScenarios":"An `[[permalinks]]` array entry (TOML) or list item (YAML) that defines `target` or other keys but omits `pattern`; a misspelled key like `patern` or `Pattern` nested wrongly.","commonSituations":"Partially written config while migrating from the legacy map format; copy-paste of a target block without its pattern; key typos that survive because unknown keys are ignored.","solutions":["Add a `pattern` string to each permalinks array entry.","Check for typos in the key name — it must be exactly `pattern` (case-insensitive config keys are cleaned, but the key must be present).","Remove empty/stub permalinks entries."],"exampleFix":"# before\n[[permalinks]]\n[permalinks.target]\nkind = \"page\"\npath = \"/posts/**\"\n\n# after\n[[permalinks]]\npattern = \"/:year/:slug/\"\n[permalinks.target]\nkind = \"page\"\npath = \"/posts/**\"","handlingStrategy":"validation","validationCode":"if pattern == \"\" { return fmt.Errorf(\"permalink pattern for %q is empty\", section) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave a permalink key with an empty string value; delete the key instead","Check for accidental `section = \"\"` left over from templating config files","Validate generated configs before running hugo"],"tags":["hugo","config","permalinks"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}