{"record":{"id":"ecb66ad28f2e6752","repo":"gohugoio/hugo","slug":"failed-to-init-mount-d-w","errorCode":null,"errorMessage":"failed to init mount %d: %w","messagePattern":"failed to init mount (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/config.go","lineNumber":233,"sourceCode":"\t\t\t\tc.replacementsMap[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])\n\t\t\t}\n\t\t}\n\n\t\tif c.replacementsMap != nil && c.Imports != nil {\n\t\t\tfor i, imp := range c.Imports {\n\t\t\t\tif newImp, found := c.replacementsMap[imp.Path]; found {\n\t\t\t\t\timp.Path = newImp\n\t\t\t\t\timp.pathProjectReplaced = true\n\t\t\t\t\tc.Imports[i] = imp\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor i, mnt := range c.Mounts {\n\t\t\tmnt.Source = filepath.Clean(mnt.Source)\n\t\t\tmnt.Target = filepath.Clean(mnt.Target)\n\t\t\tif err := mnt.init(logger); err != nil {\n\t\t\t\treturn c, fmt.Errorf(\"failed to init mount %d: %w\", i, err)\n\t\t\t}\n\t\t\tc.Mounts[i] = mnt\n\t\t}\n\n\t\tif c.Workspace == \"\" {\n\t\t\tc.Workspace = WorkspaceDisabled\n\t\t}\n\t\tif c.Workspace != WorkspaceDisabled {\n\t\t\tc.Workspace = filepath.Clean(c.Workspace)\n\t\t\tif !filepath.IsAbs(c.Workspace) {\n\t\t\t\tworkingDir := cfg.GetString(\"workingDir\")\n\t\t\t\tc.Workspace = filepath.Join(workingDir, c.Workspace)\n\t\t\t}\n\t\t\tif _, err := os.Stat(c.Workspace); err != nil {\n\t\t\t\t//lint:ignore ST1005 end user message.\n\t\t\t\treturn c, fmt.Errorf(\"module workspace %q does not exist. Check your module.workspace setting (or HUGO_MODULE_WORKSPACE env var).\", c.Workspace)\n\t\t\t}\n\t\t}","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/config.go#L215-L251","documentation":"In decodeConfig (modules/config.go:233) every user-declared [[module.mounts]] entry has its source/target cleaned and then mnt.init(logger) called. Failure wraps the zero-based mount index. This is the user-config counterpart of error 485.","triggerScenarios":"A [[module.mounts]] entry in your config (or a theme/module config) provides an invalid sites.matrix / lang combination that Mount.init rejects during normalization.","commonSituations":"Hand-editing mounts and introducing a malformed sites.matrix; mixing the deprecated 'lang' key with sites.matrix on the same mount; themes shipping outdated mount configs after a Hugo upgrade.","solutions":["Inspect the mount at the reported index and fix its sites.matrix / remove legacy lang key.","Update the theme/module to a version compatible with your Hugo release.","Validate the full [[module.mounts]] block for consistent keys."],"exampleFix":"// before (mount at reported index)\n[[module.mounts]]\nsource = \"assets\"\ntarget = \"assets\"\nlang = \"en\"\n\n// after\n[[module.mounts]]\nsource = \"assets\"\ntarget = \"assets\"","handlingStrategy":"validation","validationCode":"for i := range cfg.Module.Mounts {\n    m := &cfg.Module.Mounts[i]\n    if m.Source == \"\" || m.Target == \"\" {\n        return fmt.Errorf(\"mount #%d: source and target required\", i)\n    }\n    if m.Lang != \"\" && len(m.Sites.Matrix.Languages) > 0 {\n        return fmt.Errorf(\"mount #%d: choose either lang or sites.matrix\", i)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't combine legacy mount.lang with sites.matrix.","Validate mounts in a config preflight step.","Pin theme versions known to match your Hugo release."],"tags":["hugo","module-mounts","configuration"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}