{"record":{"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":"exception","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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/page/page_matcher.go#L398-L423","documentation":"Returned by PageMatcherParamsConfigs.InitConfig when compileSitesMatrix fails for a specific cascade target. The %w wraps the underlying glob or sites-matrix compilation error, and %d is the zero-based index of the failing cascade entry. This runs during site initialization after all cascade config is decoded.","triggerScenarios":"A cascade target with an invalid sites.matrix configuration — e.g. malformed glob patterns in the sites.matrix.languages field, or dimension values that the sitesmatrix builder cannot compile. The error identifies which cascade entry (by index) caused the failure.","commonSituations":"Setting target.sites.matrix.languages to an invalid glob or a language code that does not exist in the site's configured languages; migrating to the new sites.matrix API from the deprecated lang field with a syntax error; mismatched matrix dimension configuration.","solutions":["Read the wrapped error for the specific compilation failure (e.g. invalid glob syntax).","Use the index %d in the error message to find the exact cascade entry in your config, then fix its target.sites.matrix block.","Verify that all language codes in sites.matrix.languages match languages defined under [languages] in hugo.toml.","If unsure about the sites.matrix syntax, remove it and use the simpler target approach, or consult the Hugo target documentation."],"exampleFix":"# before (hugo.toml) — invalid language glob in sites.matrix\n[cascade]\n  [[cascade.target]]\n    sites.matrix.languages = [\"en\", \"fr\", \"xyz*\"]\n  [cascade.params]\n    layout = \"custom\"\n\n# after — use valid language codes or globs matching configured languages\n[cascade]\n  [[cascade.target]]\n    sites.matrix.languages = [\"en\", \"fr\"]\n  [cascade.params]\n    layout = \"custom\"","handlingStrategy":"validation","validationCode":"// Validate sites.matrix configuration before InitConfig\nfunc validateSitesMatrix(languages []string, configuredLangs []string) error {\n    langSet := make(map[string]bool)\n    for _, l := range configuredLangs {\n        langSet[l] = true\n    }\n    for _, l := range languages {\n        g, err := hglob.GetGlob(l)\n        if err != nil {\n            return fmt.Errorf(\"invalid language glob %q: %w\", l, err)\n        }\n        _ = g // glob compilation itself is the common failure point\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure every language code in target.sites.matrix.languages matches a [languages.xx] entry in hugo.toml.","Use simple language codes (en, fr, de) rather than complex globs unless you understand the matching.","The error includes the cascade index — use it to locate the failing entry quickly.","Migrate from the deprecated target.lang to target.sites.matrix.languages to stay on the supported API."],"tags":["hugo","cascade","sites-matrix","multilingual","config-validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}