{"id":"8f33fdca3a23550a","repo":"gohugoio/hugo","slug":"failed-to-create-page-meta-from-file-q-w","errorCode":null,"errorMessage":"failed to create page meta from file %q: %w","messagePattern":"failed to create page meta from file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/content_map.go","lineNumber":313,"sourceCode":"\t\tpageSourceCount += pc\n\t\tresourceSourceCount += rc\n\t\tif err != nil {\n\t\t\taddErr = err\n\t\t\treturn\n\t\t}\n\n\tdefault:\n\t\tm.s.Log.Trace(logg.StringFunc(\n\t\t\tfunc() string {\n\t\t\t\treturn fmt.Sprintf(\"insert bundle: %q\", fi.Meta().Filename)\n\t\t\t},\n\t\t))\n\n\t\tpageSourceCount++\n\n\t\tpm, err := h.newPageMetaSourceFromFile(fi)\n\t\tif err != nil {\n\t\t\taddErr = fmt.Errorf(\"failed to create page meta from file %q: %w\", fi.Meta().Filename, err)\n\t\t\treturn\n\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","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/content_map.go#L295-L331","documentation":"In the default branch of pageMap.AddFi — a standalone (non-bundled, non-data) content file — Hugo builds page metadata via newPageMetaSourceFromFile and wraps any failure with the filename. Like the bundled variant, it means a file on the content walk could not be parsed into a page, and the wrapped error carries the root cause.","triggerScenarios":"During hugo build/server, a top-level content file (e.g. content/posts/foo.md, _index.md) fails page-meta creation: unparseable front matter, invalid front matter values (dates, cascade, build options), or I/O errors opening the source file.","commonSituations":"Broken YAML/TOML front matter in a regular page or _index.md; invalid cascade or build blocks after a Hugo upgrade tightened validation; wrong front matter delimiter mix (--- opening, +++ closing); files corrupted by editors or sync tools.","solutions":["Fix the front matter of the file named in the error message; the wrapped error identifies the exact parse failure.","Validate structured front matter fields (date, cascade, build, aliases) against the current Hugo version's schema — upgrades can turn warnings into errors.","Verify the file is readable and valid UTF-8 (re-save without BOM/UTF-16 if a sync tool mangled it)."],"exampleFix":"// before (content/about.md)\n+++\ntitle = \"About\"\n---\n// after\n+++\ntitle = \"About\"\n+++","handlingStrategy":"try-catch","validationCode":"// lint front matter of the named file before building\ncontent, err := os.ReadFile(path)\nif err != nil { return err }\nif _, err := pageparser.ParseBytes(content, pageparser.Config{}); err != nil {\n    return fmt.Errorf(\"front matter in %q: %w\", path, err)\n}","typeGuard":null,"tryCatchPattern":"if err := site.Build(); err != nil {\n    if strings.Contains(err.Error(), \"failed to create page meta\") {\n        // the wrapped cause is a front matter/metadata problem in the quoted file\n    }\n    return err\n}","preventionTips":["Errors here are almost always front matter metadata: wrong types (string where date expected), bad cascade blocks, invalid aliases","Run a full `hugo` build in CI on every content change","Use archetypes so new pages start with known-good front matter"],"tags":["hugo","content","frontmatter","build"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}