{"record":{"id":"daddbded0ba789ae","repo":"gohugoio/hugo","slug":"module-q-not-found-in-q-either-add-it-as-a-hugo","errorCode":null,"errorMessage":"module %q not found in %q; either add it as a Hugo Module or store it in %q.","messagePattern":"module %q not found in %q; either add it as a Hugo Module or store it in %q\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":323,"sourceCode":"\n\t\t\t\t\tmod = c.gomods.GetByPath(modulePath)\n\t\t\t\t\tif mod != nil {\n\t\t\t\t\t\tmoduleDir = mod.Dir\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Fall back to project/themes/<mymodule>\n\t\t\tif moduleDir == \"\" {\n\t\t\t\tvar err error\n\t\t\t\tmoduleDir, err = c.createThemeDirname(modulePath, owner.projectMod || moduleImport.pathProjectReplaced)\n\t\t\t\tif err != nil {\n\t\t\t\t\tc.err = err\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t\tif found, _ := afero.Exists(c.fs, moduleDir); !found {\n\t\t\t\t\t//lint:ignore ST1005 end user message.\n\t\t\t\t\tc.err = c.wrapModuleNotFound(fmt.Errorf(`module %q not found in %q; either add it as a Hugo Module or store it in %q.`, modulePath, moduleDir, c.ccfg.ThemesDir))\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif found, _ := afero.Exists(c.fs, moduleDir); !found {\n\t\tc.err = c.wrapModuleNotFound(fmt.Errorf(\"%q not found\", moduleDir))\n\t\treturn nil, nil\n\t}\n\n\tif !strings.HasSuffix(moduleDir, fileSeparator) {\n\t\tmoduleDir += fileSeparator\n\t}\n\n\tma := &moduleAdapter{\n\t\tdir:          moduleDir,\n\t\tvendor:       vendored,","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/collect.go#L305-L341","documentation":"The primary 'module/theme not found' error. After all resolution paths fail (not a Go module, not downloadable, not in gomods), Hugo falls back to themesDir; if that directory does not exist, wrapModuleNotFound produces this user-facing message naming the module path, the looked-up themesDir path, and the themesDir location to store it. It tells the user the two valid ways to provide a module.","triggerScenarios":"A `[[module.imports]] path = \"mytheme\"` where mytheme is neither a resolvable Go module path nor a directory under the configured themesDir (themes/mytheme). Also when module support is disabled (no go.mod/Hugo Modules) and the theme was never placed in themes/.","commonSituations":"Typo'd theme name, theme cloned into the wrong folder, themesDir overridden in config so themes live elsewhere than expected, missing `git clone` of the theme, or running on a fresh checkout without `--recurse-submodules` / `hugo mod get`.","solutions":["Clone/install the theme into the themesDir shown in the error: `git clone <url> themes/mytheme`.","Fix the import path spelling to match the installed folder or the Go module path exactly.","If themesDir is overridden in config, place the theme under that configured directory.","For a Go-module theme, ensure Hugo Modules are enabled (`hugo mod get github.com/x/y`) and go is installed."],"exampleFix":"// before (hugo.toml)\n[[module.imports]]\npath = \"my-them\"  // typo\n// after\n[[module.imports]]\npath = \"my-theme\"\n// and ensure themes/my-theme exists:\ngit clone https://github.com/me/my-theme themes/my-theme","handlingStrategy":"validation","validationCode":"// Pre-check: theme folder or Go module must exist before build\nimport \"os\"\n\nfunc ensureThemePresent(themesDir, importPath string) error {\n  candidate := filepath.Join(themesDir, importPath)\n  if _, err := os.Stat(candidate); err == nil { return nil }\n  // not local -> must be a fetchable Go module\n  return fmt.Errorf(\"%s missing under %s and not a Go module\", importPath, themesDir)\n}","typeGuard":"null","tryCatchPattern":"// On ErrorContains 'not found in', prompt the user to clone the theme or run `hugo mod get`.","preventionTips":["Clone themes into the configured themesDir in your setup script.","Use --recurse-submodules or `hugo mod get` in CI.","Double-check import path spelling against the folder/module name.","Document the themesDir if overridden."],"tags":["modules","config","hugo-module","theme"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}