Debian Codegraph @

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

raw
1 ---
2 title: AlternativeOutputFormats
3 description: Returns a slice of OutputFormat objects, excluding the current output format, each representing one of the output formats enabled for the given page.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.OutputFormats
9 signatures: [PAGE.AlternativeOutputFormats]
10 ---
11
12 {{% glossary-term "output format" %}}
13
14 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][].
15
16 For example, to generate a `link` element for each of the alternative output formats:
17
18 ```go-html-template
19 {{ range .AlternativeOutputFormats }}
20 {{ printf "<link rel=%q type=%q href=%q>" .Rel .MediaType.Type .Permalink | safeHTML }}
21 {{ end }}
22 ```
23
24 Hugo renders this to something like:
25
26 ```html
27 <link rel="alternate" type="application/rss+xml" href="https://example.org/index.xml">
28 <link rel="alternate" type="application/json" href="https://example.org/index.json">
29 ```
30
31 [details]: /configuration/output-formats/