{"id":"9ddff25266f9636b","repo":"gohugoio/hugo","slug":"failed-to-parse-dimension-q-w","errorCode":null,"errorMessage":"failed to parse dimension %q: %w","messagePattern":"failed to parse dimension %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/page.go","lineNumber":540,"sourceCode":"func (ps *pageState) SiteVector() sitesmatrix.Vector {\n\treturn ps.s.siteVector\n}\n\nfunc (ps *pageState) siteVector() sitesmatrix.Vector {\n\treturn ps.s.siteVector\n}\n\nfunc (ps *pageState) siteVectors() sitesmatrix.VectorIterator {\n\treturn ps.s.siteVector\n}\n\n// Rotate returns all pages in the given dimension for this page.\nfunc (ps *pageState) Rotate(dimensionStr string) (page.Pages, error) {\n\tdimensionStr = strings.ToLower(dimensionStr)\n\tkey := ps.Path() + \"/\" + \"rotate-\" + dimensionStr\n\td, err := sitesmatrix.ParseDimension(dimensionStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse dimension %q: %w\", dimensionStr, err)\n\t}\n\n\tpages, err := ps.s.pageMap.getOrCreatePagesFromCache(ps.s.pageMap.cachePages2, key, func(string) (page.Pages, error) {\n\t\tvar pas page.Pages\n\t\tps.s.pageMap.treePages.ForEeachInDimension(ps.Path(), ps.s.siteVector, d,\n\t\t\tfunc(n contentNode) bool {\n\t\t\t\tif n != nil {\n\t\t\t\t\tp := n.(page.Page)\n\t\t\t\t\tpas = append(pas, p)\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t},\n\t\t)\n\n\t\tif dimensionStr == \"language\" && ps.m.pageConfig.TranslationKey != \"\" {\n\t\t\t// translationKey set by user.\n\t\t\t// This is an old construct back from when languages were introduced.\n\t\t\t// We keep it for backward compatibility.","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/page.go#L522-L558","documentation":"Returned by pageState.Rotate when the dimension string passed to it cannot be parsed by sitesmatrix.ParseDimension. Rotate returns all variants of a page along one axis of Hugo's sites matrix (e.g. language), and the dimension argument must name a known matrix dimension; anything else is rejected with the parse error wrapped.","triggerScenarios":"Calling `.Rotate \"<dim>\"` from a template (or the API) with a string that ParseDimension rejects — a misspelled or unsupported dimension name; the input is lowercased first, so it's the name itself that is wrong, not casing.","commonSituations":"Guessing dimension names (e.g. \"lang\" vs \"language\"), using a dimension from a newer Hugo version's sites-matrix feature on an older release, or passing a page/front-matter variable that is empty or holds the wrong value.","solutions":["Pass a valid dimension name recognized by sitesmatrix.ParseDimension (see sitesmatrix package / Hugo docs for the sites matrix, e.g. \"language\").","If the dimension comes from a variable, validate it or guard the call with `with` before invoking .Rotate.","Confirm your Hugo version supports the sites-matrix dimension you're using; upgrade if it was added later."],"exampleFix":"<!-- before -->\n{{ range .Rotate \"lang\" }}...{{ end }}\n<!-- after -->\n{{ range .Rotate \"language\" }}...{{ end }}","handlingStrategy":"validation","validationCode":"// Front matter images/videos dimension strings must be WxH integers\n// e.g. \"1200x630\" — validate before committing content:\nre := regexp.MustCompile(`^\\d+x\\d+$`)\nif !re.MatchString(dim) {\n    return fmt.Errorf(\"bad dimension %q, want WIDTHxHEIGHT\", dim)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write dimensions as integer WIDTHxHEIGHT (e.g. 1200x630) with a lowercase x and no units or spaces","Validate front matter in CI (archetype or schema check) so malformed dimensions fail before a build","Don't template dimension values from variables that may be empty"],"tags":["hugo","sites-matrix","templates","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}