Skip to content

Custom media type stale documentation #6480

Description

@JensRantil

I am following https://gohugo.io/templates/output-formats/#media-types and added the following to my config:

[mediaTypes]
   [mediaTypes."text/plantuml"]
     suffix = "plantuml"

Hugo compilation complains with

$ hugo serve -D
Error: from config: MediaType.Suffix is removed. Before Hugo 0.44 this was used both to set a custom file suffix and as way
to augment the mediatype definition (what you see after the "+", e.g. "image/svg+xml").

This had its limitations. For one, it was only possible with one file extension per MIME type.

Now you can specify multiple file suffixes using "suffixes", but you need to specify the full MIME type
identifier:

[mediaTypes]
[mediaTypes."image/svg+xml"]
suffixes = ["svg", "abc" ]

In most cases, it will be enough to just change:

[mediaTypes]
[mediaTypes."my/custom-mediatype"]
suffix = "txt"

To:

[mediaTypes]
[mediaTypes."my/custom-mediatype"]
suffixes = ["txt"]

Note that you can still get the Media Type's suffix from a template: {{ $mediaType.Suffix }}. But this will now map to the MIME type filename.

I guess the documentation needs to be updated?

What version of Hugo are you using (hugo version)?

https://gohugo.io/templates/output-formats/#media-types

$ hugo version
Hugo Static Site Generator v0.58.3/extended darwin/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Not sure. Probably.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions