{"id":"a9d3b805bd873004","repo":"gohugoio/hugo","slug":"s-mount-target-must-be-one-of-v","errorCode":null,"errorMessage":"%s: mount target must be one of: %v","messagePattern":"(.+?): mount target must be one of: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":871,"sourceCode":"\t\t\t\t\t_, err := c.fs.Stat(sourceDir)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tmnt.Source = sourceDir\n\t\t\t\t} else {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Verify that target points to one of the predefined component dirs\n\t\ttargetBase := mnt.Target\n\t\tidxPathSep := strings.Index(mnt.Target, string(os.PathSeparator))\n\t\tif idxPathSep != -1 {\n\t\t\ttargetBase = mnt.Target[0:idxPathSep]\n\t\t}\n\t\tif !files.IsComponentFolder(targetBase) {\n\t\t\treturn nil, fmt.Errorf(\"%s: mount target must be one of: %v\", errMsg, files.ComponentFolders)\n\t\t}\n\n\t\tif err := mnt.init(c.logger.Logger()); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%s: %w\", errMsg, err)\n\t\t}\n\n\t\tout = append(out, mnt)\n\t}\n\n\treturn out, nil\n}\n\nfunc (c *collector) wrapModuleNotFound(err error) error {\n\tif c.Client.ccfg.IgnoreModuleDoesNotExist {\n\t\treturn nil\n\t}\n\terr = fmt.Errorf(err.Error()+\": %w\", ErrNotExist)\n\tif c.GoModulesFilename == \"\" {","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/collect.go#L853-L889","documentation":"When normalizing module mounts, Hugo verifies that the first path segment of each mount's `target` is one of the predefined Hugo component folders (content, data, layouts, i18n, archetypes, assets, static). A target outside that set has no meaning in Hugo's virtual filesystem, so collection fails with the list of valid folders.","triggerScenarios":"A `[[module.mounts]]` entry (in project, theme, or module config) whose `target` first segment is not a component folder — e.g. `target = \"public\"`, `target = \"themes/x\"`, a typo like `layout` or `contents`, or an absolute target path.","commonSituations":"Typos in the target (`asset` vs `assets`); trying to mount into the output/publish dir; confusing `source` and `target` order; using pre-Hugo-modules directory names or custom directories not in ComponentFolders.","solutions":["Fix the mount `target` so it starts with one of: content, data, layouts, i18n, archetypes, assets, static (subpaths under those are fine, e.g. `assets/js`).","Check you didn't swap `source` and `target` in the mount block.","If you wanted a custom output location, mount into `static` or `assets` and handle placement via Hugo pipes/templates instead."],"exampleFix":"# before\n[[module.mounts]]\nsource = \"dist\"\ntarget = \"public/js\"\n\n# after\n[[module.mounts]]\nsource = \"dist\"\ntarget = \"assets/js\"","handlingStrategy":"validation","validationCode":"var validTargets = map[string]bool{\"content\": true, \"data\": true, \"layouts\": true, \"i18n\": true, \"archetypes\": true, \"assets\": true, \"static\": true}\nfor _, m := range cfg.Mounts {\n    root := strings.SplitN(filepath.ToSlash(m.Target), \"/\", 2)[0]\n    if !validTargets[root] {\n        return fmt.Errorf(\"invalid mount target %q\", m.Target)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mount targets must start with one of Hugo's component folders (content, data, layouts, i18n, archetypes, assets, static)","Copy mount stanzas from Hugo docs rather than hand-typing target names","Validate config with `hugo config` in CI to catch bad mounts before deploy"],"tags":["hugo-modules","config","mounts","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}