{"id":"37e4bd4b077371c5","repo":"gohugoio/hugo","slug":"errpermalinkattributeunknown","errorCode":"errPermalinkAttributeUnknown","errorMessage":"permalink attribute not recognised","messagePattern":"permalink attribute not recognised","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/permalinks.go","lineNumber":272,"sourceCode":"\t})\n}\n\n// pageToPermaAttribute is the type of a function which, given a page and a tag\n// can return a string to go in that position in the page (or an error)\ntype pageToPermaAttribute func(Page, string) (string, error)\n\nvar attributeRegexp = regexp.MustCompile(`:\\w+(\\[.+?\\])?`)\n\ntype permalinkExpandError struct {\n\tpattern string\n\terr     error\n}\n\nfunc (pee *permalinkExpandError) Error() string {\n\treturn fmt.Sprintf(\"error expanding %q: %s\", pee.pattern, pee.err)\n}\n\nvar errPermalinkAttributeUnknown = errors.New(\"permalink attribute not recognised\")\n\nfunc (l PermalinkExpander) pageToPermalinkDate(p Page, dateField string) (string, error) {\n\t// a Page contains a Node which provides a field Date, time.Time\n\tswitch dateField {\n\tcase \"year\":\n\t\treturn strconv.Itoa(p.Date().Year()), nil\n\tcase \"month\":\n\t\treturn fmt.Sprintf(\"%02d\", int(p.Date().Month())), nil\n\tcase \"monthname\":\n\t\treturn p.Date().Month().String(), nil\n\tcase \"day\":\n\t\treturn fmt.Sprintf(\"%02d\", p.Date().Day()), nil\n\tcase \"weekday\":\n\t\treturn strconv.Itoa(int(p.Date().Weekday())), nil\n\tcase \"weekdayname\":\n\t\treturn p.Date().Weekday().String(), nil\n\tcase \"yearday\":\n\t\treturn strconv.Itoa(p.Date().YearDay()), nil","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/page/permalinks.go#L254-L290","documentation":"Hugo compiles each permalink pattern by matching `:attribute` tokens (regexp `:\\w+(\\[.+?\\])?`) against its table of known permalink attributes (:year, :month, :day, :slug, :title, :section, :sections, :filename, :slugorfilename, plus date-format and taxonomy variants). A token that isn't in that table — and isn't a page front-matter field usable as an attribute — produces errPermalinkAttributeUnknown, wrapped with the offending pattern, and the config fails to load.","triggerScenarios":"A `permalinks` entry containing an unrecognized `:token`, e.g. `posts = \"/:categories/:slug/\"` when no matching attribute or front-matter field resolves, or misspellings like `:filename` vs `:file`, `:sections[1]` syntax errors.","commonSituations":"Typos (`:tittle`, `:yearmonth`); using another SSG's tokens (Jekyll's `:categories` semantics); expecting a custom front-matter field to work when the field name collides with nothing known; wrong `:sections[...]` range syntax.","solutions":["Check the pattern quoted in the error and compare each `:token` against Hugo's documented permalink tokens (gohugo.io/content-management/urls/#tokens); fix the spelling.","For custom values, use a front-matter field whose name matches the token, or set `url` in front matter instead.","For section slices use the documented syntax, e.g. `/:sections[last]/` or `/:sections[1:]/`."],"exampleFix":"# before\n[permalinks]\n  posts = '/:yearmonth/:slug/'\n# after\n[permalinks]\n  posts = '/:year/:month/:slug/'","handlingStrategy":"validation","validationCode":"var knownAttrs = map[string]bool{\"year\": true, \"month\": true, \"monthname\": true, \"day\": true, \"weekday\": true, \"weekdayname\": true, \"yearday\": true, \"section\": true, \"sections\": true, \"title\": true, \"slug\": true, \"slugorfilename\": true, \"filename\": true, \"contentbasename\": true}\nfor _, m := range regexp.MustCompile(`:(\\w+)`).FindAllStringSubmatch(pattern, -1) {\n    if !knownAttrs[strings.ToLower(m[1])] {\n        return fmt.Errorf(\"unknown permalink attribute :%s in %q\", m[1], pattern)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only attributes documented for Hugo permalinks (:year, :slug, :section, :title, etc.)","Remember taxonomy pages support a narrower attribute set than regular pages","Check the docs for your exact Hugo version — available attributes have changed across releases"],"tags":["hugo","permalinks","config","urls"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}