hugo/docs/content/en/methods/page/OutputFormats.md
Bjørn Erik Pedersen 5fd1e74903
Merge commit '9b0050e9aabe4be65c78ccf292a348f309d50ccd' as 'docs'
```
git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash
```

Closes #11925
2024-01-27 10:48:57 +01:00

1.1 KiB

title description categories keywords action toc
OutputFormats Returns a slice of OutputFormat objects, each representing one of the output formats enabled for the given page.
related returnType signatures
methods/page/AlternativeOutputFormats
[]OutputFormat
PAGE.OutputFormats
true

{{% include "methods/page/_common/output-format-definition.md" %}}

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

{{% include "methods/page/_common/output-format-methods.md" %}}

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.