{"id":"d646f21c448c0f9b","repo":"gohugoio/hugo","slug":"unsupported-format-provided","errorCode":null,"errorMessage":"unsupported Format provided","messagePattern":"unsupported Format provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"parser/frontmatter.go","lineNumber":74,"sourceCode":"\t\t}\n\n\t\t_, err = w.Write(b)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = w.Write([]byte{'\\n'})\n\t\treturn err\n\tcase metadecoders.XML:\n\t\tb, err := xml.AnyXmlIndent(in, \"\", \"\\t\", \"root\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = w.Write(b)\n\t\treturn err\n\tdefault:\n\t\treturn errors.New(\"unsupported Format provided\")\n\t}\n}\n\nfunc InterfaceToFrontMatter(in any, format metadecoders.Format, w io.Writer) error {\n\tif in == nil {\n\t\treturn errors.New(\"input was nil\")\n\t}\n\n\tswitch format {\n\tcase metadecoders.YAML:\n\t\t_, err := w.Write([]byte(yamlDelimLf))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\terr = InterfaceToConfig(in, format, w)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/parser/frontmatter.go#L56-L92","documentation":"parser.InterfaceToConfig only knows how to marshal to YAML, TOML, JSON, and XML; any other metadecoders.Format value falls through to this error. It guards against a zero-value or decode-only Format (like CSV or ORG, which Hugo can read but not write here) being used for serialization.","triggerScenarios":"Calling InterfaceToConfig/InterfaceToFrontMatter with a Format that is empty (zero value from FormatFromString on an unknown string) or one without a marshal branch — e.g. metadecoders.CSV or metadecoders.ORG. Reached via `hugo convert` and new-content/archetype code when the target format string doesn't resolve.","commonSituations":"Passing a mistyped or unsupported format name to `hugo convert` or to front matter output settings (e.g. \"yml\" handled, but arbitrary strings not); programmatic use where FormatFromString returned \"\" and the caller didn't check; trying to emit front matter as ORG/CSV, which Hugo only decodes.","solutions":["Use one of the supported output formats: yaml, toml, json, or xml.","If resolving the format from a string, check that metadecoders.FormatFromString returned a non-empty Format before calling InterfaceToConfig.","For org-mode or CSV targets, convert to a supported format instead — Hugo cannot marshal those."],"exampleFix":"// before\nf := metadecoders.FormatFromString(userInput)\nerr := parser.InterfaceToConfig(v, f, w)\n// after\nf := metadecoders.FormatFromString(userInput)\nif f == \"\" {\n    return fmt.Errorf(\"unknown format %q; use yaml, toml, json or xml\", userInput)\n}\nerr := parser.InterfaceToConfig(v, f, w)","handlingStrategy":"type-guard","validationCode":"f := metadecoders.FormatFromString(ext)\nif f == \"\" {\n    return fmt.Errorf(\"unknown front matter format for %q\", ext)\n}","typeGuard":"func isFrontMatterFormat(f metadecoders.Format) bool {\n    switch f {\n    case metadecoders.YAML, metadecoders.TOML, metadecoders.JSON, metadecoders.ORG:\n        return true\n    }\n    return false\n}","tryCatchPattern":"b, err := parser.InterfaceToFrontMatter(in, format)\nif err != nil {\n    if strings.Contains(err.Error(), \"unsupported Format\") {\n        // default to YAML or ask the caller for a valid format\n    }\n    return err\n}","preventionTips":["Only pass front matter formats (yaml, toml, json, org) — not generic data formats like CSV/XML","Resolve the format from the file extension via the library helpers rather than hard-coding strings","Validate user-configurable front matter format settings at startup, not per-page"],"tags":["hugo","frontmatter","marshal","data-format"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}