Debian Codegraph @

docs/content/en/configuration/outputs.md

raw
1 ---
2 title: Configure outputs
3 linkTitle: Outputs
4 description: Configure which output formats to render for each page kind.
5 categories: []
6 keywords: []
7 ---
8
9 {{% glossary-term "output format" %}}
10
11 Learn more about creating and configuring output formats in the [configure output formats][] section.
12
13 ## Outputs per page kind
14
15 The following default configuration determines the output formats generated for each page kind:
16
17 {{< code-toggle config=outputs />}}
18
19 To render the built-in `json` output format for the `home` page kind, assuming you've already created the necessary template, add the following to your configuration:
20
21 {{< code-toggle file=hugo >}}
22 [outputs]
23 home = ['html','rss','json']
24 {{< /code-toggle >}}
25
26 Notice in this example that we only specified the `home` page kind. You don't need to include entries for other page kinds unless you intend to modify their default output formats.
27
28 > [!NOTE]
29 > The order of the output formats in the arrays above is important. The first element will be the _primary output format_ for that page kind, and in most cases that should be `html` as shown in the default configuration.
30 >
31 > The primary output format for a given page kind determines the value returned by the [`Permalink`][] and [`RelPermalink`][] methods on a `Page` object.
32 >
33 > See the [link to output formats][] section for details.
34
35 ## Outputs per page
36
37 Add output formats to a page's rendering using the `outputs` field in its front matter. For example, to include `json` in the output formats rendered for a specific page:
38
39 {{< code-toggle file=content/example.md fm=true >}}
40 title = 'Example'
41 outputs = ['json']
42 {{< /code-toggle >}}
43
44 In its default configuration, Hugo will render both the `html` and `json` output formats for this page. The `outputs` field appends to, rather than replaces, the project's configured outputs.
45
46 [`Permalink`]: /methods/page/permalink/
47 [`RelPermalink`]: /methods/page/relpermalink/
48 [configure output formats]: /configuration/output-formats/
49 [link to output formats]: configuration/output-formats/#link-to-output-formats