gohugoio/hugo · error
MIME not supported
Error message
MIME %q not supported
What it means
When transform.Unmarshal receives a Resource without an explicit format option, it derives the format from the resource's MediaType suffixes via metadecoders.FormatFromStrings (unmarshal.go:81-85). If none of the media-type suffixes map to a supported format (org/json/toml/yaml/csv/xml), the resource's MediaType is reported as unsupported.
Solutions
- Provide an explicit format option: {{ transform.Unmarshal (dict "format" "json") $res }}.
- Ensure the resource's file extension maps to a known media type in hugo.toml ([mediaTypes]).
- Verify the resource is the expected type before unmarshalling (e.g. check MediaType.String()).
Example fix
// before — MediaType not recognized, no explicit format
{{ transform.Unmarshal $remoteResource }}
// after — pass explicit format
{{ transform.Unmarshal (dict "format" "csv") $remoteResource }} Defensive patterns
Strategy: validation
Validate before calling
// Provide an explicit format instead of relying on MediaType inference:
{{ transform.Unmarshal (dict "format" "csv") $res }}
// Or ensure the resource MediaType has a suffix mapped in hugo.toml [mediaTypes]. Prevention
- Pass an explicit 'format' option for resources with generic/unknown media types.
- Register custom [mediaTypes] in hugo.toml with recognizable suffixes.
- Check the resource MediaType before unmarshalling remote/custom resources.
When it happens
Trigger: Passing a Resource whose MediaType suffixes are not among the recognized set — e.g. a text/plain, application/pdf, or a custom media type without a known suffix. Encountered when no explicit format is provided.
Common situations: Fetching a remote resource with {{ resources.GetRemote }} that returns a generic content type; a custom media type configured in hugo.toml without a matching suffix; a resource whose file extension isn't registered; passing a Page or non-Resource value that has an unexpected MediaType.
Related errors
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/7c81c4b3611da293.
Report an issue: GitHub.
Appendix: source
Thrown at tpl/transform/unmarshal.go:84
if key == "" {
return nil, errors.New("no Key set in Resource")
}
if decoder != metadecoders.Default {
key += decoder.OptionsKey()
}
v, err := ns.cacheUnmarshal.GetOrCreate(key, func(string) (*resources.StaleValue[any], error) {
var f metadecoders.Format
if decoder.Format != "" {
f = metadecoders.FormatFromString(decoder.Format)
if f == "" {
return nil, fmt.Errorf("format %q not supported", decoder.Format)
}
} else {
f = metadecoders.FormatFromStrings(r.MediaType().Suffixes()...)
if f == "" {
return nil, fmt.Errorf("MIME %q not supported", r.MediaType())
}
}
reader, err := r.ReadSeekCloser()
if err != nil {
return nil, err
}
defer reader.Close()
b, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
v, err := decoder.Unmarshal(b, f)
if err != nil {
return nil, err
}View on GitHub (pinned to 52c9bd7908)