mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
40
docs/content/en/methods/page/OutputFormats.md
Normal file
40
docs/content/en/methods/page/OutputFormats.md
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: OutputFormats
|
||||
description: Returns a slice of OutputFormat objects, each representing one of the output formats enabled for the given page.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/AlternativeOutputFormats
|
||||
returnType: '[]OutputFormat'
|
||||
signatures: [PAGE.OutputFormats]
|
||||
toc: 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](/templates/output-formats/).
|
||||
|
||||
## Methods
|
||||
|
||||
{{% include "methods/page/_common/output-format-methods.md" %}}
|
||||
|
||||
## Example
|
||||
|
||||
To link to the RSS feed for the current page:
|
||||
|
||||
```go-html-template
|
||||
{{ with .OutputFormats.Get "rss" -}}
|
||||
<a href="{{ .RelPermalink }}">RSS Feed</a>
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
On the site's home page, Hugo renders this to:
|
||||
|
||||
```html
|
||||
<a href="/index.xml">RSS Feed</a>
|
||||
```
|
||||
|
||||
Please see the [link to output formats] section to understand the importance of the construct above.
|
||||
|
||||
[link to output formats]: /templates/output-formats/#link-to-output-formats
|
Reference in New Issue
Block a user