{"id":"45c2b548bd3c3af9","repo":"gohugoio/hugo","slug":"failed-to-create-page-from-file-q-w","errorCode":null,"errorMessage":"failed to create page from file %q: %w","messagePattern":"failed to create page from file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/content_map.go","lineNumber":263,"sourceCode":"\tif m == nil {\n\t\tpanic(\"nil pageMap\")\n\t}\n\n\th := m.s.h\n\n\tinsertResource := func(fim hugofs.FileMetaInfo) error {\n\t\tresourceSourceCount++\n\t\tpi := fi.Meta().PathInfo\n\t\tkey := pi.Base()\n\t\ttree := m.treeResources\n\n\t\ttree.Lock(true)\n\t\tdefer tree.Unlock(true)\n\n\t\tif pi.IsContent() {\n\t\t\tpm, err := h.newPageMetaSourceFromFile(fi)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create page from file %q: %w\", fi.Meta().Filename, err)\n\t\t\t}\n\t\t\tpm.bundled = true\n\t\t\tm.treeResources.Insert(key, pm)\n\t\t} else {\n\t\t\tr := func() (hugio.ReadSeekCloser, error) {\n\t\t\t\treturn fim.Meta().Open()\n\t\t\t}\n\t\t\t// Create one dimension now, the rest later on demand.\n\t\t\trs := &resourceSource{path: pi, opener: r, fi: fim, sv: fim.Meta().SitesMatrix.VectorSample()}\n\t\t\tm.treeResources.Insert(key, rs)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tmeta := fi.Meta()\n\tpi := meta.PathInfo\n","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/hugolib/content_map.go#L245-L281","documentation":"In pageMap.AddFi's insertResource closure, a bundled content file (a content-typed file inside a page bundle) is turned into page metadata via newPageMetaSourceFromFile; if that fails, the error is wrapped with the source filename and aborts the build walk. It means Hugo found a content file in a bundle but could not parse it into a page — almost always a front matter problem.","triggerScenarios":"During the content walk (hugo build/server), a file recognized as content (pi.IsContent()) inside a leaf/branch bundle fails newPageMetaSourceFromFile — malformed front matter delimiters, invalid YAML/TOML/JSON front matter, invalid dates, or an unreadable file.","commonSituations":"A markdown file in a page bundle with broken front matter (missing closing --- or +++, tabs in YAML, invalid TOML date); merge-conflict markers in content files; files with a content extension that aren't actually content; encoding issues (UTF-16/BOM oddities) in bundled pages.","solutions":["Open the file named in the error and fix its front matter — check delimiters and validate the YAML/TOML syntax the wrapped error points at.","Check date/param values in front matter (invalid dates are a frequent wrapped cause).","If the file isn't meant to be a page, rename it to a non-content extension or move it out of the bundle so it's treated as a plain resource."],"exampleFix":"// before (content/post/my-bundle/notes.md)\n---\ntitle: Notes\ndate: 2026-13-40\n--\nBody\n// after\n---\ntitle: Notes\ndate: 2026-07-31\n---\nBody","handlingStrategy":"try-catch","validationCode":"// sanity-check the content file before the build touches it\nfi, err := os.Stat(path)\nif err != nil || fi.IsDir() {\n    return fmt.Errorf(\"bad content file %q\", path)\n}","typeGuard":null,"tryCatchPattern":"if err := build(); err != nil {\n    // wrapped error: unwrap to find the root cause (front matter parse, bad date, etc.)\n    fmt.Fprintf(os.Stderr, \"content build failed: %v\\n\", err)\n    var root error = err\n    for errors.Unwrap(root) != nil { root = errors.Unwrap(root) }\n    // report root alongside the quoted filename from the message\n}","preventionTips":["The %q in the message names the failing file — start debugging there, usually malformed front matter","Validate content with `hugo --panicOnWarning` or a CI build before merging content PRs","Keep front matter delimiters balanced (--- / +++) and dates in RFC3339 or configured formats"],"tags":["hugo","content","frontmatter","build"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}