{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/convert.go#L130-L166","documentation":"During front-matter conversion (hugo convert), convertAndSavePage constructs an errMsg for the file being processed (convert.go:148) and logs it via site.Log.Errorln when the file cannot be opened or its front matter cannot be parsed by pageparser. Open failures are logged and swallowed (returns nil so conversion continues); parse failures are logged and returned, stopping the conversion.","triggerScenarios":"A content file with corrupted or unparseable front matter, or a file that cannot be read (permissions, encoding issues) during hugo convert toJSON/toTOML/toYAML.","commonSituations":"Malformed front-matter delimiters; invalid TOML/YAML/JSON in front matter; permission issues reading the file; binary or encoding problems.","solutions":["Fix the malformed front matter in the indicated file","Verify the file's read permissions","Manually validate the front-matter syntax (e.g. with a TOML/YAML linter)","Run hugo convert on a clean checkout to rule out file corruption"],"exampleFix":"# before: broken front matter\n+++\ntitle = \"My Post\ndate 2024-01-01\n+++\n# after: valid TOML\n+++\ntitle = \"My Post\"\ndate = 2024-01-01\n+++","handlingStrategy":"try-catch","validationCode":"// Pre-validate front-matter syntax before running hugo convert.\nfunc validateFrontMatter(path string) error {\n    f, err := os.Open(path)\n    if err != nil {\n        return err\n    }\n    defer f.Close()\n    _, err = pageparser.ParseFrontMatterAndContent(f)\n    return err\n}","typeGuard":null,"tryCatchPattern":"// hugo convert logs and continues on open errors; handle the returned parse error.\nif err := cmd.convertContents(format); err != nil {\n    if strings.Contains(err.Error(), \"error processing file\") {\n        log.Printf(\"some files had parse errors; check output\")\n    }\n}","preventionTips":["Lint front matter in content files before converting","Back up content before running hugo convert","Run hugo convert on a clean git working tree to detect corruption"],"tags":["convert","frontmatter","content","cli","pageparser","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}