{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/import.go#L309-L345","documentation":"After parsing, the importer calls `convertJekyllMetaData` to translate Jekyll front matter (permalink, category, layout, date) into Hugo conventions. This wraps a failure in that conversion step; `%q` is the filename, `%s` the underlying error (typically from `hmaps.ToStringMapE`).","triggerScenarios":"Fires when front matter cannot be coerced into a `map[string]any` (e.g. it parsed as a scalar or array), or a field-level transformation encounters an unexpected type such as a non-string `permalink`/`category` that still fails the type assertion path.","commonSituations":"A Jekyll post whose front matter root is a list or bare string instead of an object; a `permalink`/`category` value that is a nested structure rather than a scalar; front matter produced by a plugin with non-standard schema.","solutions":["Inspect the named file's front matter and ensure it is a YAML/TOML object (map).","Flatten nested or array-shaped front matter values before importing.","Manually fix the offending metadata and re-run the import for that file.","Pre-process the Jekyll export to normalize front matter types."],"exampleFix":"// before\n---\npermalink:\n  en: /post/hello/\n---\n// after\n---\nurl: /post/hello/\n---","handlingStrategy":"validation","validationCode":"// Ensure front matter root is a mapping before importing.\nfunc frontMatterIsMap(b []byte) bool {\n  pf, err := pageparser.ParseFrontMatterAndContent(bytes.NewReader(b))\n  if err != nil { return false }\n  _, ok := pf.FrontMatter.(map[string]any)\n  return ok\n}","typeGuard":"null","tryCatchPattern":"// Treat metadata conversion as best-effort and continue.\nif _, err := convertJekyllMetaData(...); err != nil {\n  log.Printf(\"metadata convert failed for %s: %v\", filename, err)\n  // fall back to writing metadata as-is or skip\n}","preventionTips":["Normalize Jekyll front matter to a flat object map before importing.","Avoid nested values for fields Hugo expects as scalars (permalink, category).","Pre-process exports from other CMSs into standard Jekyll schema."],"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"}