{"id":"4b79777d306e18a9","repo":"gohugoio/hugo","slug":"failed-to-read-page-content-w","errorCode":null,"errorMessage":"failed to read page content: %w","messagePattern":"failed to read page content: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"parser/pageparser/pageparser.go","lineNumber":63,"sourceCode":"\t\treturn nil, err\n\t}\n\treturn l.items, l.err\n}\n\ntype ContentFrontMatter struct {\n\tContent           []byte\n\tFrontMatter       map[string]any\n\tFrontMatterFormat metadecoders.Format\n}\n\n// ParseFrontMatterAndContent is a convenience method to extract front matter\n// and content from a content page.\nfunc ParseFrontMatterAndContent(r io.Reader) (ContentFrontMatter, error) {\n\tvar cf ContentFrontMatter\n\n\tinput, err := io.ReadAll(r)\n\tif err != nil {\n\t\treturn cf, fmt.Errorf(\"failed to read page content: %w\", err)\n\t}\n\n\tpsr, err := ParseBytes(input, Config{})\n\tif err != nil {\n\t\treturn cf, err\n\t}\n\n\tvar frontMatterSource []byte\n\n\titer := NewIterator(psr)\n\n\twalkFn := func(item Item) bool {\n\t\tif frontMatterSource != nil {\n\t\t\t// The rest is content.\n\t\t\tcf.Content = input[item.low:]\n\t\t\t// Done\n\t\t\treturn false\n\t\t} else if item.IsFrontMatter() {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/parser/pageparser/pageparser.go#L45-L81","documentation":"Returned by ParseFrontMatterAndContent (parser/pageparser/pageparser.go:63) when io.ReadAll on the supplied reader fails before any parsing happens. It is an I/O failure reading the raw page bytes, not a front matter syntax error — those surface from ParseBytes afterwards.","triggerScenarios":"Any caller of pageparser.ParseFrontMatterAndContent (e.g. hugo import/convert commands, tooling embedding Hugo) passing a reader whose Read errors: a closed or unreadable file handle, a failing network/pipe reader, or a filesystem error mid-read.","commonSituations":"Content files with permission problems, files on network mounts or synced folders (Dropbox/OneDrive placeholders) that error on read, files deleted between stat and read during `hugo convert`, or truncated/locked files on Windows.","solutions":["Check the wrapped error for the OS-level cause (permission denied, input/output error).","Verify file permissions and ownership of the content file: ls -l content/...","If the file lives on a sync/network mount, ensure it is fully hydrated locally before building.","Re-run the command; if it persists, copy the file locally to rule out filesystem faults."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fi, err := os.Stat(path)\nif err != nil { return err }\nif !fi.Mode().IsRegular() {\n    return fmt.Errorf(\"%s: not a regular file\", path)\n}\n// ensure the reader you pass is fresh and not already consumed/closed","typeGuard":null,"tryCatchPattern":"items, err := pageparser.ParseBytes(b, cfg)\nif err != nil {\n    return fmt.Errorf(\"parse %s: %w\", path, err)\n}","preventionTips":["Verify content files are readable regular files (not sockets/dirs/broken symlinks) before parsing","Pass a fresh io.Reader; don't reuse a reader that may already be drained or closed","Guard against truncated/partial writes: write content files atomically (temp file + rename)"],"tags":["hugo","io","content","pageparser"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}