{"id":"8618a6ee103fb979","repo":"gohugoio/hugo","slug":"failed-to-convert-metadata-for-file-q-s","errorCode":null,"errorMessage":"failed to convert metadata for file %q: %s","messagePattern":"failed to convert metadata for file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/import.go","lineNumber":327,"sourceCode":"\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\nfunc (c *importCommand) copyJekyllFilesAndFolders(jekyllRoot, dest string, jekyllPostDirs map[string]bool) (err error) {\n\tfs := hugofs.Os\n\n\tfi, err := fs.Stat(jekyllRoot)","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/import.go#L309-L345","documentation":"Emitted by Hugo's `hugo import jekyll` command in `convertJekyllPost` when `convertJekyllMetaData` fails to transform a Jekyll post's front matter into Hugo-compatible metadata. Hugo parses each post's front matter and rewrites Jekyll-specific keys (layout, permalink, date, draft status) into Hugo front matter; if that transformation errors, the whole conversion of that file aborts with this wrapped error.","triggerScenarios":"Running `hugo import jekyll <jekyllRoot> <target>` on a post whose front matter parses but contains metadata that convertJekyllMetaData cannot convert — e.g. malformed or unexpected date values, non-map front matter structures, or values whose types don't match what the converter expects.","commonSituations":"Migrating an old Jekyll blog where posts have hand-edited or plugin-generated front matter; posts with unusual date formats in front matter overriding the filename date; YAML values with unexpected types (arrays where scalars are expected).","solutions":["Read the wrapped underlying error message after the filename to identify the offending front matter key.","Open the named Jekyll post and fix or normalize the invalid front matter (especially date fields) so it is valid YAML with expected types.","Re-run the import; convert stubborn posts manually by copying content and writing Hugo front matter by hand."],"exampleFix":"# before (post front matter)\n---\ndate: 31/12/2015\n---\n# after\n---\ndate: 2015-12-31\n---","handlingStrategy":"try-catch","validationCode":"// Pre-parse the front matter yourself before invoking import\nif _, err := metadecoders.Default.UnmarshalToMap(frontMatter, metadecoders.YAML); err != nil {\n    log.Printf(\"skipping %s: bad metadata: %v\", path, err)\n}","typeGuard":null,"tryCatchPattern":"if err := convertJekyllPost(path); err != nil {\n    if strings.Contains(err.Error(), \"failed to convert metadata\") {\n        // log the file and continue with remaining posts\n    }\n    return err\n}","preventionTips":["Lint Jekyll front matter (valid YAML, closed --- fences) before running hugo import","Normalize non-standard date/tag fields in the source posts first","Run the import on a copy so partial failures don't corrupt originals"],"tags":["hugo","jekyll-import","front-matter","cli"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}