{"record":{"id":"a2697374f96b6c59","repo":"gohugoio/hugo","slug":"failed-to-convert-content-for-file-q-s","errorCode":null,"errorMessage":"failed to convert content for file %q: %s","messagePattern":"failed to convert content for file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/import.go","lineNumber":332,"sourceCode":"\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\nfunc (c *importCommand) copyJekyllFilesAndFolders(jekyllRoot, dest string, jekyllPostDirs map[string]bool) (err error) {\n\tfs := hugofs.Os\n\n\tfi, err := fs.Stat(jekyllRoot)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !fi.IsDir() {\n\t\treturn errors.New(jekyllRoot + \" is not a directory\")","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/import.go#L314-L350","documentation":"After metadata conversion, `convertJekyllContent` rewrites the body (Liquid tags, `{{ }}` includes, Jekyll-specific syntax) into Hugo/Markdown form. This wraps any failure during that content rewriting pass; `%q` is the filename, `%s` the conversion error.","triggerScenarios":"Fires when the content converter hits a construct it cannot translate — an unsupported Jekyll/Liquid tag, a malformed include, or an error returned by a regex-based rewrite in `convertJekyllContent`.","commonSituations":"Jekyll posts with custom Liquid plugins (`{% tag %}`) that have no Hugo equivalent; a post using `{% include %}` with arguments the importer cannot parse; corrupted UTF-8 in the body that breaks content rewriting.","solutions":["Open the named file and locate the Liquid/Jekyll-specific tags the importer flagged.","Replace unsupported tags with Markdown or Hugo shortcodes manually.","Re-run the import after fixing; conversion is per-file so the rest succeeds.","Audit the Jekyll export for third-party plugin syntax before importing."],"exampleFix":"// before\n{% youtube maxmustermann abc123 %}\n// after\n{{< youtube abc123 >}}","handlingStrategy":"fallback","validationCode":"// Pre-scan for unsupported Liquid tags so you can replace them ahead of import.\nfunc hasUnsupportedLiquid(b []byte) bool {\n  re := regexp.MustCompile(`\\{%.*%\\}`)\n  return re.Match(b)\n}","typeGuard":"null","tryCatchPattern":"// Fall back to importing the raw body if content conversion fails,\n// so the post isn't lost entirely.\ncontent, err := convertJekyllContent(meta, body)\nif err != nil {\n  log.Printf(\"content convert failed for %s: %v\", filename, err)\n  content = body // keep original Markdown\n}","preventionTips":["Audit the Jekyll export for plugin-specific Liquid tags before importing.","Replace custom tags with Hugo shortcodes in a pre-processing step.","Import posts individually to localize content-conversion failures."],"tags":["hugo","import","jekyll","content"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}