{"id":"280a920c7eeb0599","repo":"gohugoio/hugo","slug":"module-q-not-found","errorCode":null,"errorMessage":"module %q not found","messagePattern":"module %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":287,"sourceCode":"\n\tif moduleDir == \"\" {\n\t\tif requestedVersionQuery == \"\" {\n\t\t\tmod = c.gomods.GetByPath(modulePath)\n\t\t\tif mod != nil {\n\t\t\t\tmoduleDir = mod.Dir\n\t\t\t}\n\t\t}\n\n\t\tif moduleDir == \"\" {\n\t\t\tif isProbablyModule(modulePath) {\n\t\t\t\tif requestedVersionQuery != \"\" {\n\t\t\t\t\tvar err error\n\t\t\t\t\tmod, err = c.downloadModuleVersion(modulePath, requestedVersionQuery)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tif mod == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"module %q not found\", modulePath)\n\t\t\t\t\t}\n\t\t\t\t\tmoduleDir = mod.Dir\n\t\t\t\t\tversionMod = mod.Version\n\t\t\t\t} else if c.GoModulesFilename != \"\" {\n\t\t\t\t\t// See https://golang.org/ref/mod#version-queries\n\t\t\t\t\t// This will select the latest release-version (not beta etc.).\n\t\t\t\t\tconst versionQuery = \"upgrade\"\n\t\t\t\t\t// Try to \"go get\" it and reload the module configuration.\n\n\t\t\t\t\t// Note that we cannot use c.Get for this, as that may\n\t\t\t\t\t// trigger a new module collection and potentially create a infinite loop.\n\t\t\t\t\tif err := c.get(fmt.Sprintf(\"%s@%s\", modulePath, versionQuery)); err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tif err := c.loadModules(); err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/collect.go#L269-L305","documentation":"In `collector.add` (modules/collect.go:287), when an import has an explicit version query (e.g. `path@v1.2.0`), Hugo calls `downloadModuleVersion`; if that returns no module and no error, Hugo reports `module %q not found`. It means the Go toolchain could not produce a module matching that path at the requested version.","triggerScenarios":"An import with `version` set in module config (or a `path@version` reference) where `go` downloads nothing for that path/version combination — nonexistent tag, wrong module path casing, or a version query matching no release.","commonSituations":"Pinning a theme to a tag that was deleted or never pushed; requesting `v2.x` of a module whose go.mod path lacks the `/v2` suffix; typos in the path; proxy caches missing a very fresh tag.","solutions":["Verify the version exists: `go list -m -versions <modulepath>` or check the repo's tags.","For major versions ≥2, use the `/v2` (etc.) suffixed module path.","Remove the version pin to let Hugo select the latest release, then re-pin to a real tag.","If the tag is brand new, retry with `GOPROXY=direct` to bypass a stale proxy cache."],"exampleFix":"# before\n[[module.imports]]\npath = \"github.com/org/theme\"\nversion = \"v2.0.0\"   # module path for v2 is theme/v2\n# after\n[[module.imports]]\npath = \"github.com/org/theme/v2\"\nversion = \"v2.0.0\"","handlingStrategy":"validation","validationCode":"// Check every configured import resolves: entries in config `module.imports`\n// must appear in go.mod or exist on disk\nfor _, imp := range cfg.Imports {\n    if !knownModule(imp.Path) { /* fix config or run hugo mod get */ }\n}","typeGuard":null,"tryCatchPattern":"if err := build(); err != nil {\n    if strings.Contains(err.Error(), \"not found\") {\n        // config imports a module absent from go.mod / module cache\n    }\n    return err\n}","preventionTips":["Keep `module.imports` in the site config in sync with go.mod","After removing a theme/module from config, run `hugo mod tidy`","Spell module paths exactly (case-sensitive) as published"],"tags":["hugo-modules","versioning","go-toolchain","configuration"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}