{"record":{"id":"63d68990f349077e","repo":"gohugoio/hugo","slug":"unsupported-data-file-extension-q","errorCode":null,"errorMessage":"unsupported data file extension %q","messagePattern":"unsupported data file extension %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/content_map.go","lineNumber":333,"sourceCode":"\t\t}\n\n\t\tm.treePages.InsertWithLock(pm.pathInfo.Base(), pm)\n\t}\n\treturn\n}\n\nfunc (m *pageMap) addPagesFromGoTmplFi(fi hugofs.FileMetaInfo, buildConfig *BuildCfg) (pageCount uint64, resourceCount uint64, addErr error) {\n\tmeta := fi.Meta()\n\tpi := meta.PathInfo\n\n\tm.s.Log.Trace(logg.StringFunc(\n\t\tfunc() string {\n\t\t\treturn fmt.Sprintf(\"insert pages from data file: %q\", fi.Meta().Filename)\n\t\t},\n\t))\n\n\tif !files.IsGoTmplExt(pi.Ext()) {\n\t\taddErr = fmt.Errorf(\"unsupported data file extension %q\", pi.Ext())\n\t\treturn\n\t}\n\n\tsitesMatrix := fi.Meta().SitesMatrix\n\n\ts := m.s.h.resolveFirstSite(sitesMatrix)\n\th := s.h\n\n\tcontentAdapter := s.pageMap.treePagesFromTemplateAdapters.Get(pi.Base())\n\tvar rebuild bool\n\tif contentAdapter != nil {\n\t\t// Rebuild\n\t\tcontentAdapter = contentAdapter.CloneForGoTmpl(fi)\n\t\trebuild = true\n\t} else {\n\t\tcontentAdapter = pagesfromdata.NewPagesFromTemplate(\n\t\t\tpagesfromdata.PagesFromTemplateOptions{\n\t\t\t\tGoTmplFi: fi,","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/content_map.go#L315-L351","documentation":"Returned by addPagesFromGoTmplFi when a file routed as TypeContentData (a Go-template data file that generates pages) has an extension that is not a Go-template extension (files.IsGoTmplExt returns false). Hugo's data-driven page generation requires .tmpl/.gotmpl/.html templates; any other extension placed in the content data path is unsupported.","triggerScenarios":"A file under /content with a path type that routes it into the content-data (pages-from-template) pipeline but whose extension is not .tmpl/.gotmpl/.html — e.g. a misplaced .json, .yaml, .csv, or .txt that the path classifier treated as content data. This indicates a path/classification mismatch.","commonSituations":"Placing a data file (.json/.yaml) directly in /content expecting it to be data when Hugo expects it under /data; a content-nested template misnamed; a custom mediaTypes/paths config reclassifying extensions unexpectedly; upgrading Hugo where content-data routing changed.","solutions":["If the file is a page-generating template, rename it to use .tmpl or .gotmpl (e.g. mypages.html.tmpl).","If the file is meant as data, move it to /data (Hugo's data source) instead of /content.","Review mediaTypes and module mounts to ensure the extension is classified as intended.","Check the path type logic: only files the path parser tags as TypeContentData reach this branch."],"exampleFix":"# before\n/content/books.json   (rejected: unsupported data file extension \".json\")\n# after\n/data/books.json      (data file) OR\n/content/books.tmpl   (page-generating template)","handlingStrategy":"type-guard","validationCode":"func isGoTmplExt(ext string) bool {\n    switch strings.ToLower(strings.TrimPrefix(ext, \".\")) {\n    case \"tmpl\", \"gotmpl\", \"html\": return true\n    }\n    return false\n}","typeGuard":"func isContentDataTemplate(fi hugofs.FileMetaInfo) bool {\n    return fi.Meta().PathInfo != nil && fi.Meta().PathInfo.Type() == paths.TypeContentData && isGoTmplExt(fi.Meta().PathInfo.Ext())\n}","tryCatchPattern":null,"preventionTips":["Use .tmpl/.gotmpl/.html for content-data page generators under /content.","Put non-template data under /data, not /content.","Review mediaTypes/module mounts when changing how extensions are classified."],"tags":["content-data","template","extension","paths","content-map","hugolib"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}