OutputFormats
Syntax
PAGE.OutputFormats
Returns
[]OutputFormat
Hugo generates one or more files per page when building a site. For example, when rendering home, section, taxonomy, and term pages, Hugo generates an HTML file and an RSS file. Both HTML and RSS are built-in output formats. Create multiple output formats, and control generation based on page kind, or by enabling one or more output formats for one or more pages. See details.
The OutputFormats
method on a Page
object returns a slice of OutputFormat
objects, each representing one of the output formats enabled for the given page. See details.
Methods
- Get IDENTIFIER
- (
any
) Returns theOutputFormat
object with the given identifier. - MediaType
- (
media.Type
) Returns the media type of the output format. - MediaType.MainType
- (
string
) Returns the main type of the output format’s media type. - MediaType.SubType
- (
string
) Returns the subtype of the current format’s media type. - Name
- (
string
) Returns the output identifier of the output format. - Permalink
- (
string
) Returns the permalink of the page generated by the current output format. - Rel
- (
string
) Returns therel
value of the output format, either the default or as defined in the site configuration. - RelPermalink
- (
string
) Returns the relative permalink of the page generated by the current output format.
Example
To link to the RSS feed for the current page:
{{ with .OutputFormats.Get "rss" -}}
<a href="{{ .RelPermalink }}">RSS Feed</a>
{{ end }}
On the site’s home page, Hugo renders this to:
<a href="/index.xml">RSS Feed</a>
Please see the link to output formats section to understand the importance of the construct above.