{"record":{"id":"0f29bd55fc0bc202","repo":"gohugoio/hugo","slug":"permalink-attribute-not-recognised","errorCode":null,"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/page/permalinks.go#L254-L290","documentation":"Permalink patterns use `:attr` tokens expanded from a fixed map (`knownPermalinkAttributes` at permalinks.go:113-131: year/month/monthname/day/weekday/weekdayname/yearday/section/sectionslug/sections/sectionslugs/title/slug/slugorfilename/filename/contentbasename/slugorcontentbasename). During pattern compilation, any token not in that map yields this error wrapped as `error expanding ...` (permalinks.go:228).","triggerScenarios":"Configuring `permalinks` in hugo.toml with a pattern containing an unknown `:token`, e.g. `:author` or `:category` (note: taxonomies are not permalink attributes), or a typo like `:sectoin`.","commonSituations":"Assuming taxonomy terms are available as `:tag`/`:category`; typo in a known attribute; following an outdated doc listing different tokens; trying to reference a custom param via `:myparam`.","solutions":["Use only the documented `:attributes` (year, month, day, section, title, slug, filename, sections, sectionslug, sectionslugs, contentbasename, slugorfilename, slugorcontentbasename, etc.).","For custom params/taxonomies, build URLs differently — permalink attributes don't expand arbitrary params.","Fix typos in attribute names."],"exampleFix":"# before\n[permalinks]\nposts = \"/posts/:year/:author/:slug/\"\n\n# after\n[permalinks]\nposts = \"/posts/:year/:sections/:slug/\"","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"year\":true,\"month\":true,\"monthname\":true,\"day\":true,\"weekday\":true,\"weekdayname\":true,\"yearday\":true,\"section\":true,\"sectionslug\":true,\"sections\":true,\"sectionslugs\":true,\"title\":true,\"slug\":true,\"slugorfilename\":true,\"filename\":true,\"contentbasename\":true,\"slugorcontentbasename\":true}\nfor _, m := range attributeRegexp.FindAllStringSubmatch(pattern, -1) {\n    name := strings.TrimPrefix(m[0], \":\")\n    if i := strings.IndexByte(name, '['); i >= 0 { name = name[:i] }\n    if !valid[name] { return fmt.Errorf(\"permalink attribute %q not recognised\", name) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only documented :attributes in permalink patterns.","Taxonomy terms are not permalink attributes.","Lint permalink patterns in CI."],"tags":["hugo","configuration","permalinks","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}