gohugoio/hugo · error
failed to detect target data serialization format
Error message
failed to detect target data serialization format
What it means
Thrown by transform.Remarshal when the target format argument is not one of the recognized serialization formats (tpl/transform/remarshal.go:81-86, via toFormatMark). The format is lowercased and trimmed, then matched; anything other than json/yaml/toml fails.
Solutions
- Use one of: json, yaml, or toml.
- Check for typos and stray whitespace in the format argument.
- If the format comes from a variable, validate it against the allowed set.
Example fix
// before
{{ transform.Remarshal "ymal" .Data }}
// after
{{ transform.Remarshal "yaml" .Data }} Defensive patterns
Strategy: validation
Validate before calling
{{/* Only json, yaml, toml allowed */}}
{{ transform.Remarshal "yaml" .Data }} Prevention
- Restrict format strings to json/yaml/toml.
- Validate dynamic format variables against the allowed set.
When it happens
Trigger: Calling {{ transform.Remarshal "xml" .Data }} or {{ transform.Remarshal "JSON5" .Data }} (case aside, unrecognized names) or with a typo like {{ transform.Remarshal "ymal" .Data }}.
Common situations: Typos in the format string; assuming an unsupported format like XML/INI/CSV is supported; trailing spaces or newlines in the format variable.
Related errors
- failed to detect format from content
- first argument must be a map
- must provide at least one argument
- transform.Highlight: expects at most 3 arguments
- unmarshal takes 1 or 2 arguments
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/5e5106b91f09e2ad.
Report an issue: GitHub.
Appendix: source
Thrown at tpl/transform/remarshal.go:86
for k, v := range m {
switch t := v.(type) {
case map[string]any:
applyMarshalTypes(t)
case float64:
i := int64(t)
if t == float64(i) {
m[k] = i
}
}
}
}
func toFormatMark(format string) (metadecoders.Format, error) {
if f := metadecoders.FormatFromString(format); f != "" {
return f, nil
}
return "", errors.New("failed to detect target data serialization format")
}
View on GitHub (pinned to 52c9bd7908)