{"id":"d943247129e5f869","repo":"gohugoio/hugo","slug":"error-processing-file-q","errorCode":null,"errorMessage":"error processing file %q","messagePattern":"error processing file %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/convert.go","lineNumber":148,"sourceCode":"\t}\n\tc.h = h\n\treturn nil\n}\n\nfunc (c *convertCommand) convertAndSavePage(p page.Page, site *hugolib.Site, targetFormat metadecoders.Format) error {\n\t// The resources are not in .Site.AllPages.\n\tfor _, r := range p.Resources().ByType(\"page\") {\n\t\tif err := c.convertAndSavePage(r.(page.Page), site, targetFormat); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif p.File() == nil {\n\t\t// No content file.\n\t\treturn nil\n\t}\n\n\terrMsg := fmt.Errorf(\"error processing file %q\", p.File().Path())\n\n\tsite.Log.Infoln(\"attempting to convert\", p.File().Filename())\n\n\tf := p.File()\n\tfile, err := f.FileInfo().Meta().Open()\n\tif err != nil {\n\t\tsite.Log.Errorln(errMsg)\n\t\tfile.Close()\n\t\treturn nil\n\t}\n\n\tpf, err := pageparser.ParseFrontMatterAndContent(file)\n\tif err != nil {\n\t\tsite.Log.Errorln(errMsg)\n\t\tfile.Close()\n\t\treturn err\n\t}\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/convert.go#L130-L166","documentation":"Logged (and sometimes returned) by `hugo convert` when a content file cannot be opened or its front matter parsed during format conversion (commands/convert.go:148-165). It is created once per page as a shared message, then emitted if `Meta().Open()` fails or `pageparser.ParseFrontMatterAndContent` cannot split the file into front matter and body.","triggerScenarios":"Running `hugo convert toTOML|toYAML|toJSON` over a content tree containing a file that (a) can't be opened from the filesystem (permissions, deleted mid-run, broken symlink), or (b) has malformed front matter — unclosed `---`/`+++` delimiters, invalid YAML/TOML/JSON inside the front matter block, or stray BOM/encoding issues that break the page parser.","commonSituations":"Content imported from another SSG with slightly different front-matter delimiters; a merge conflict marker (`<<<<<<<`) left inside front matter; files with Windows-1252/UTF-16 encoding; unreadable files owned by another user in Docker volumes.","solutions":["Note the file path in the log line and open that file — verify its front matter block has matching opening/closing delimiters (`---` for YAML, `+++` for TOML, `{...}` for JSON) and valid syntax inside.","Validate the front matter with a standalone parser (e.g. paste the YAML into yamllint) and fix the reported syntax error.","Check the file is readable (permissions, not a broken symlink) and UTF-8 encoded.","Re-run the convert; only the offending file blocks — fix files one by one as reported."],"exampleFix":"# before (content/post/a.md)\n---\ntitle: \"My post\ndate: 2024-01-01\n--\n# after\n---\ntitle: \"My post\"\ndate: 2024-01-01\n---","handlingStrategy":"try-catch","validationCode":"info, err := os.Stat(path)\nif err != nil || info.IsDir() {\n    // skip: not a readable regular file\n}","typeGuard":null,"tryCatchPattern":"if err := convertFile(path); err != nil {\n    log.Printf(\"skipping %q: %v\", path, err)\n    continue // process remaining files; report failures at the end\n}","preventionTips":["Run conversion on a clean git tree so a partial failure is trivially revertable","Validate front matter parses before running bulk conversion (hugo --printPathWarnings, dry runs)","Collect per-file errors and report them in aggregate instead of aborting on the first"],"tags":["hugo","convert","front-matter","content","parsing"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}