Back to Hugo

AlternativeOutputFormats

docs/content/en/methods/page/AlternativeOutputFormats.md

0.161.1772 B
Original Source

{{% glossary-term "output format" %}}

The AlternativeOutputFormats method on a Page object returns a slice of OutputFormat objects, excluding the current output format, each representing one of the output formats enabled for the given page. See details.

For example, to generate a link element for each of the alternative output formats:

go-html-template
{{ range .AlternativeOutputFormats }}
  {{ printf "<link rel=%q type=%q href=%q>" .Rel .MediaType.Type .Permalink | safeHTML }}
{{ end }}

Hugo renders this to something like:

html
<link rel="alternate" type="application/rss+xml" href="https://example.org/index.xml">
<link rel="alternate" type="application/json" href="https://example.org/index.json">