{"id":"021de5ae95e4c970","repo":"gohugoio/hugo","slug":"failed-to-compile-cascade-target-d-w","errorCode":null,"errorMessage":"failed to compile cascade target %d: %w","messagePattern":"failed to compile cascade target (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/page/page_matcher.go","lineNumber":416,"sourceCode":"\t}\n\treturn h.Sum64()\n}\n\nfunc (c *PageMatcherParamsConfigs) InitConfig(logger loggers.Logger, defaultsIn sitesmatrix.VectorStore, configuredDimensions *sitesmatrix.ConfiguredDimensions) error {\n\tif c == nil {\n\t\treturn nil\n\t}\n\tfor _, cc := range c.c {\n\t\tfor i := range cc.Config.Cascades {\n\t\t\tccc := cc.Config.Cascades[i]\n\t\t\tcheckCascadePattern(logger, ccc.Target)\n\t\t\tdefaults := defaultsIn\n\t\t\thasSitesMatrix := ccc.hasSitesMatrix()\n\t\t\tif hasSitesMatrix {\n\t\t\t\tdefaults = nil\n\t\t\t}\n\t\t\tif err := ccc.Target.compileSitesMatrix(defaults, configuredDimensions); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to compile cascade target %d: %w\", i, err)\n\t\t\t}\n\t\t\tcc.Config.Cascades[i] = ccc\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":398,"sourceCodeEnd":423,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/page/page_matcher.go#L398-L423","documentation":"`PageMatcherParamsConfigs.InitConfig` walks each configured cascade and compiles its `_target` sites matrix (languages and other site dimensions) against the site's configured dimensions. When `compileSitesMatrix` fails for cascade entry number `%d`, the error is wrapped with the cascade's index so you can find the offending block in an otherwise anonymous list. The wrapped `%w` cause carries the real reason, typically an unknown language or dimension value.","triggerScenarios":"Defining `[[cascade]]` entries whose `_target` includes `lang`/`languages` or other sites-matrix dimensions that are not among the site's configured dimensions; also triggered when a cascade sets a sites matrix that conflicts with the defaults for a multilingual or multi-dimension site setup.","commonSituations":"Targeting a language code that isn't in `[languages]` (e.g. `lang: en-US` when the site declares `en`); a theme or module contributing a cascade for a language the consuming site doesn't define; adding a new site dimension in config but not to every cascade target after upgrading to a Hugo release with the sites-matrix model.","solutions":["Read the wrapped cause after the colon — it names the specific dimension or value that failed to compile.","Use the index `%d` (zero-based) to locate the exact cascade entry in your config or front matter list.","Make the `_target` `lang` value exactly match a key under `[languages]` in your site config, including case and region suffix.","If the cascade comes from a theme/module, either define the missing language in your site config or override the cascade in your own config.","Run `hugo config` to dump the resolved languages and dimensions and diff them against the cascade targets."],"exampleFix":"# before — site declares only [languages.en]\ncascade:\n  - _target:\n      lang: en-US\n    banner: hero.jpg\n\n# after\ncascade:\n  - _target:\n      lang: en\n    banner: hero.jpg","handlingStrategy":"try-catch","validationCode":"// pre-validate each cascade entry's _target globs\nfor i, t := range cascadeTargets {\n    if _, err := glob.Compile(t.Path); err != nil {\n        return fmt.Errorf(\"cascade target %d has bad path glob %q: %w\", i, t.Path, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := site.Build(); err != nil {\n    var e *herrors.ErrorWithFileContext\n    if errors.As(err, &e) {\n        // config error: report file + cascade index from the wrapped message\n    }\n    return err\n}","preventionTips":["Keep cascade _target path globs syntactically valid (balanced braces, valid patterns)","The index %d in the error refers to the cascade array position — count from 0 in your config","Test config changes with hugo config or a dry build in CI"],"tags":["hugo","cascade","multilingual","sites-matrix","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}