Files
hugo/docs/content/en/methods/page/AlternativeOutputFormats.md
T
Bjørn Erik Pedersen 30a20122b7 Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82'
# Conflicts:
#	docs/data/docs.yaml
2026-02-14 12:14:33 +01:00

1.1 KiB

title, description, categories, keywords, params
title description categories keywords params
AlternativeOutputFormats Returns a slice of OutputFormat objects, excluding the current output format, each representing one of the output formats enabled for the given page.
functions_and_methods
returnType signatures
page.OutputFormats
PAGE.AlternativeOutputFormats

{{% 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:

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

Hugo renders this to something like:

<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">