{"record":{"id":"af7ec310de375eb4","repo":"gohugoio/hugo","slug":"failed-to-init-mount-q-d-w","errorCode":null,"errorMessage":"failed to init mount %q %d: %w","messagePattern":"failed to init mount %q (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/config.go","lineNumber":162,"sourceCode":"\t\t\t\t\tMatrix: sitesmatrix.StringSlices{\n\t\t\t\t\t\tLanguages: []string{l.Lang},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Static mounts are a little special.\n\t\t\tif component == files.ComponentFolderStatic {\n\t\t\t\tstaticDirs := cfg.StaticDirs()\n\t\t\t\tfor _, dir := range staticDirs {\n\t\t\t\t\tmounts = append(mounts, Mount{Sites: sites, Source: dir, Target: component})\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif dir != \"\" {\n\t\t\t\tmnt := Mount{Source: dir, Target: component, Sites: sites}\n\t\t\t\tif err := mnt.init(logger); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to init mount %q %d: %w\", lang, i, err)\n\t\t\t\t}\n\t\t\t\tmounts = append(mounts, mnt)\n\t\t\t}\n\t\t}\n\t}\n\n\tmoda.mounts = append(moda.mounts, mounts...)\n\n\tmoda.mounts = filterDuplicateMounts(moda.mounts)\n\n\treturn nil\n}\n\n// DecodeConfig creates a modules Config from a given Hugo configuration.\nfunc DecodeConfig(logger logg.Logger, cfg config.Provider) (Config, error) {\n\treturn decodeConfig(logger, cfg, nil)\n}\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/config.go#L144-L180","documentation":"Thrown inside the loop that derives default mounts from the project's component directory settings (modules/config.go:162). For each language index i and component dir (contentDir, layoutDir, assetDir, etc.), Hugo builds a Mount and calls mnt.init(logger); failure is wrapped with the language code and the iteration index.","triggerScenarios":"A default component-directory mount (auto-created from settings like contentDir/assetDir/i18nDir) fails Mount.init, typically because of an invalid sites.matrix/lang combination produced from per-language config.","commonSituations":"A multilingual setup where a per-language component dir setting conflicts with sites.matrix; upgrading Hugo versions that changed how default mounts carry language scope; malformed language configuration in languages.xx blocks.","solutions":["Review your per-language directory settings (contentDir, layoutDir, etc.) for consistency across language blocks.","Align sites.matrix configuration with your language definitions and remove legacy mount.lang overrides.","Simplify to a single language to isolate whether the issue is language-scoping specific."],"exampleFix":"// before\n[languages.fr]\ncontentDir = 'content/fr'\n# conflicting/missing matrix on a mount derived from these\n\n// after\n[languages.fr]\ncontentDir = 'content/fr'\nweight = 2","handlingStrategy":"validation","validationCode":"// validate per-language component dir settings are consistent\nfor _, lang := range cfg.Languages {\n    if lang.ContentDir == \"\" { continue }\n    if !dirExists(filepath.Join(workDir, lang.ContentDir)) {\n        return fmt.Errorf(\"language %s contentDir %q missing\", lang.Lang, lang.ContentDir)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep per-language dir settings uniform and existing.","Avoid mixing legacy mount.lang with sites.matrix.","Re-test multilingual configs after Hugo upgrades."],"tags":["hugo","configuration","multilingual"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}