{"record":{"id":"3928391510685779","repo":"gohugoio/hugo","slug":"failed-to-parse-file-q-s","errorCode":null,"errorMessage":"failed to parse file %q: %s","messagePattern":"failed to parse file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/import.go","lineNumber":323,"sourceCode":"\tif err != nil {\n\t\tc.r.Printf(\"Failed to parse filename '%s': %s. Skipping.\", filename, err)\n\t\treturn nil\n\t}\n\n\tlog.Println(filename, postDate, postName)\n\n\ttargetFile := filepath.Join(targetDir, relPath)\n\ttargetParentDir := filepath.Dir(targetFile)\n\tos.MkdirAll(targetParentDir, 0o777)\n\n\tcontentBytes, err := os.ReadFile(path)\n\tif err != nil {\n\t\tc.r.logger.Errorln(\"Read file error:\", path)\n\t\treturn err\n\t}\n\tpf, err := pageparser.ParseFrontMatterAndContent(bytes.NewReader(contentBytes))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse file %q: %s\", filename, err)\n\t}\n\tnewmetadata, err := c.convertJekyllMetaData(pf.FrontMatter, postName, postDate, draft)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to convert metadata for file %q: %s\", filename, err)\n\t}\n\n\tcontent, err := c.convertJekyllContent(newmetadata, string(pf.Content))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to convert content for file %q: %s\", filename, err)\n\t}\n\n\tfs := hugofs.Os\n\tif err := helpers.WriteToDisk(targetFile, strings.NewReader(content), fs); err != nil {\n\t\treturn fmt.Errorf(\"failed to save file %q: %s\", filename, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/import.go#L305-L341","documentation":"During `hugo import jekyll`, each Jekyll post is read and parsed with `pageparser.ParseFrontMatterAndContent`. This wraps a failure to parse the front matter + body of a Jekyll Markdown file. The `%q` is the source filename; `%s` is the parser's underlying error.","triggerScenarios":"Fires inside `convertJekyllPost` when the Jekyll file's front matter delimiters are malformed (e.g. missing trailing `---`), the YAML/TOML is invalid, or the file is not a recognized front-matter format.","commonSituations":"A Jekyll post with a missing closing `---` after YAML front matter; mixed tab/space indentation that breaks YAML; a post exported from another CMS with non-standard front matter; an empty or binary file picked up by the import glob.","solutions":["Open the named file and verify the front matter block is properly delimited with `---`.","Lint the YAML/TOML front matter with an external tool (`yamllint`).","Skip or fix the offending post and re-run the import.","Ensure the import targets text Markdown files, not binary uploads."],"exampleFix":"// before\n---\ntitle: Hello\ntags: [a, b\n---\nbody\n// after\n---\ntitle: Hello\ntags: [a, b]\n---\nbody","handlingStrategy":"validation","validationCode":"// Validate a Jekyll post's front matter delimiters before importing.\nfunc validFrontMatter(b []byte) error {\n  s := string(b)\n  if !strings.HasPrefix(s, \"---\\n\") { return fmt.Errorf(\"missing leading ---\") }\n  if strings.Count(s, \"\\n---\\n\") < 1 { return fmt.Errorf(\"missing closing ---\") }\n  return nil\n}","typeGuard":"null","tryCatchPattern":"// Per-file isolation: import Jekyll posts one at a time so a parse\n// failure is reported without aborting the whole import.\nfor _, post := range posts {\n  if err := convertJekyllPost(post, ...); err != nil {\n    log.Printf(\"skip %s: %v\", post, err); continue\n  }\n}","preventionTips":["Lint Jekyll YAML front matter (`yamllint`) before running `hugo import jekyll`.","Run the import per-file so one bad post doesn't abort the batch.","Confirm posts are UTF-8 text, not binary."],"tags":["hugo","import","jekyll","front-matter"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}