{"record":{"id":"b4dfcd3fc423140d","repo":"gohugoio/hugo","slug":"could-not-determine-content-directory-for-q","errorCode":null,"errorMessage":"could not determine content directory for %q","messagePattern":"could not determine content directory for %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/filesystems/basefs.go","lineNumber":210,"sourceCode":"\n\t}\n\n\tif !isAbs {\n\t\t// A filename on the form \"posts/mypage.md\", put it inside\n\t\t// the first content folder, usually <workDir>/content.\n\t\t// Pick the first project dir (which is probably the most important one).\n\t\tfor _, dir := range b.SourceFilesystems.Content.mounts() {\n\t\t\tif !dir.IsDir() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmeta := dir.Meta()\n\t\t\tif meta.IsProject {\n\t\t\t\treturn filename, filepath.Join(meta.Filename, filename), nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"\", \"\", fmt.Errorf(\"could not determine content directory for %q\", filename)\n}\n\n// ResolveJSConfigFile resolves the JS-related config file to a absolute\n// filename. One example of such would be postcss.config.js.\nfunc (b *BaseFs) ResolveJSConfigFile(name string) string {\n\t// First look in assets/_jsconfig\n\tfi, err := b.Assets.Fs.Stat(filepath.Join(files.FolderJSConfig, name))\n\tif err == nil {\n\t\treturn fi.(hugofs.FileMetaInfo).Meta().Filename\n\t}\n\t// Fall back to the work dir.\n\tfi, err = b.Work.Stat(name)\n\tif err == nil {\n\t\treturn fi.(hugofs.FileMetaInfo).Meta().Filename\n\t}\n\n\treturn \"\"\n}","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/filesystems/basefs.go#L192-L228","documentation":"Returned by BaseFs content-directory resolution when no project content mount can host the given filename. Hugo tries every content mount: absolute paths must match a mount's BaseDir/Filename, relative paths go into the first project content directory. If none qualifies, it gives up with this error.","triggerScenarios":"Raised when resolving where to place a content file whose absolute path does not fall under any configured content mount (no mount's Filename/BaseDir prefix matches), and the path is absolute so the 'first project dir' fallback is skipped.","commonSituations":"Misconfigured module mounts where source paths don't align with the actual filesystem layout; an absolute path passed from a tool/plugin that lives outside all mounted content roots; theme/content mount `source` pointing at the wrong directory after a repo restructure.","solutions":["Inspect the %q filename in the message and compare it against your [[mounts]] source/target in hugo config — the absolute path must be inside a mount's source.","Add or fix a content mount so the offending path is covered: target = \"content\", source = \"<dir-containing-the-file>\".","If the path is correct, ensure the mount is marked as a project mount and the directory exists.","Avoid passing absolute paths that are not under any module/project root."],"exampleFix":"// before\n[[mounts]]\nsource = \"/srv/site/pages\"\ntarget = \"content\"\n// file at /srv/site/posts/x.md -> no match (outside /srv/site/pages)\n\n// after: make the mount cover the real content root\n[[mounts]]\nsource = \"/srv/site\"\ntarget = \"content\"","handlingStrategy":"validation","validationCode":"// Validate before resolving: ensure an absolute path is under a content mount.\nfunc underContentMount(absPath string, mounts []Mount) bool {\n    for _, m := range mounts {\n        if m.Target == \"content\" && strings.HasPrefix(absPath, m.Source) {\n            return true\n        }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"rel, abs, err := b.Paths().FilenameFromBase(filename)\nif err != nil {\n    // surface the unresolvable path and skip/abort\n    h.Log.Errorf(\"content resolution: %v\", err)\n    return\n}","preventionTips":["Always pass paths relative to a content mount unless you control the mounts.","Audit [[mounts]] source/target pairs whenever restructuring the repo.","Add a CI check that every content file resolves to a mount."],"tags":["filesystem","mounts","modules","config","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}