HUGO
Menu
GitHub 88493 stars Mastodon

MediaType

Returns the media type of the given output format.

Syntax

OUTPUTFORMAT.MediaType

Returns

media.Type

To use this method you must first select a specific output format from a page’s OutputFormats collection using the Get or Canonical methods.

Example

{{ with .Site.Home.OutputFormats.Get "rss" }}
  {{ with .MediaType }}
    {{ .Type }} → application/rss+xml
    {{ .MainType }} → application
    {{ .SubType }} → rss
    {{ .Suffixes }} → [rss]
    {{ .FirstSuffix.Suffix }} → rss
  {{ end }}
{{ end }}

Methods

Use these methods on the MediaType object.

Type
(string) Returns the media type.
MainType
(string) Returns the main type of the media type.
SubType
(string) Returns the subtype of the media type.
Suffixes
(slice) Returns a slice of possible file suffixes for the media type.
FirstSuffix.Suffix
(string) Returns the first of the possible file suffixes for the media type.