You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/configuration/output-formats.md
+43-47Lines changed: 43 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,25 +44,25 @@ isHTML
44
44
: (`bool`) Whether to classify the output format as HTML. Hugo uses this value to determine when to create alias redirects and when to inject the LiveReload script. Default is `false`.
45
45
46
46
isPlainText
47
-
: (`bool`) Whether to parse templates for this output format with Go's [text/template] package instead of the [html/template] package. Default is `false`.
47
+
: (`bool`) Whether to parse templates for this output format with Go's [text/template][] package instead of the [html/template][] package. Default is `false`.
48
48
49
49
mediaType
50
-
: (`string`) The [media type](g) of the published file. This must match one of the [configured media types].
50
+
: (`string`) The [media type](g) of the published file. This must match one of the [configured media types][].
51
51
52
52
notAlternative
53
-
: (`bool`) Whether to exclude this output format from the values returned by the [`AlternativeOutputFormats`] method on a `Page` object. Default is `false`.
53
+
: (`bool`) Whether to exclude this output format from the values returned by the [`AlternativeOutputFormats`][] method on a `Page` object. Default is `false`.
54
54
55
55
noUgly
56
-
: (`bool`) Whether to disable ugly URLs for this output format when [`uglyURLs`] are enabled in your site configuration. Default is `false`.
56
+
: (`bool`) Whether to disable ugly URLs for this output format when [`uglyURLs`][] are enabled in your site configuration. Default is `false`.
57
57
58
58
path
59
-
: (`string`) The first segment of the publication path for this output format. This path segment is relative to the root of your [`publishDir`]. If omitted, Hugo will use the file's original content path for publishing.
59
+
: (`string`) The first segment of the publication path for this output format. This path segment is relative to the root of your [`publishDir`][]. If omitted, Hugo will use the file's original content path for publishing.
60
60
61
61
permalinkable
62
-
: (`bool`) Whether to return the rendering output format rather than main output format when invoking the [`Permalink`] and [`RelPermalink`] methods on a `Page` object. See [details](#link-to-output-formats). Enabled by default for the `html` and `amp` output formats. Default is `false`.
62
+
: (`bool`) Whether to return the rendering output format rather than main output format when invoking the [`Permalink`][] and [`RelPermalink`][] methods on a `Page` object. See [details](#link-to-output-formats). Enabled by default for the `html` and `amp` output formats. Default is `false`.
63
63
64
64
protocol
65
-
: (`string`) The protocol (scheme) of the URL for this output format. For example, `https://` or `webcal://`. Default is the scheme of the [`baseURL`] parameter in your site configuration, typically `https://`.
65
+
: (`string`) The protocol (scheme) of the URL for this output format. For example, `https://` or `webcal://`. Default is the scheme of the [`baseURL`][] parameter in your site configuration, typically `https://`.
66
66
67
67
rel
68
68
: (`string`) If provided, you can assign this value to `rel` attributes in `link` elements when iterating over output formats in your templates. Default is `alternate`.
@@ -93,56 +93,52 @@ The example above shows that when you modify a default content format, you only
93
93
94
94
You can create new output formats as needed. For example, you may wish to create an output format to support Atom feeds.
95
95
96
-
### Step 1
96
+
Step 1
97
+
: Output formats require a specified media type. Because Atom feeds use `application/atom+xml`, which is not one of the [default media types][], you must create it first.
97
98
98
-
Output formats require a specified media type. Because Atom feeds use `application/atom+xml`, which is not one of the [default media types], you must create it first.
99
+
{{< code-toggle file=hugo >}}
100
+
[mediaTypes.'application/atom+xml']
101
+
suffixes = ['atom']
102
+
{{< /code-toggle >}}
99
103
100
-
{{< code-toggle file=hugo >}}
101
-
[mediaTypes.'application/atom+xml']
102
-
suffixes = ['atom']
103
-
{{< /code-toggle >}}
104
-
105
-
See [configure media types] for more information.
106
-
107
-
### Step 2
108
-
109
-
Create a new output format:
110
-
111
-
{{< code-toggle file=hugo >}}
112
-
[outputFormats.atom]
113
-
mediaType = 'application/atom+xml'
114
-
noUgly = true
115
-
{{< /code-toggle >}}
104
+
See [configure media types][] for more information.
116
105
117
-
Note that we use the default settings for all other output format properties.
106
+
Step 2
107
+
: Create a new output format:
118
108
119
-
### Step 3
109
+
{{< code-toggle file=hugo >}}
110
+
[outputFormats.atom]
111
+
mediaType = 'application/atom+xml'
112
+
noUgly = true
113
+
{{< /code-toggle >}}
120
114
121
-
Specify the page [kinds](g) for which to render this output format:
115
+
Note that we use the default settings for all other output format properties.
122
116
123
-
{{< code-toggle file=hugo >}}
124
-
[outputs]
125
-
home = ['html', 'rss', 'atom']
126
-
section = ['html', 'rss', 'atom']
127
-
taxonomy = ['html', 'rss', 'atom']
128
-
term = ['html', 'rss', 'atom']
129
-
{{< /code-toggle >}}
117
+
Step 3
118
+
: Specify the page [kinds](g) for which to render this output format:
130
119
131
-
See [configure outputs] for more information.
120
+
{{< code-toggle file=hugo >}}
121
+
[outputs]
122
+
home = ['html', 'rss', 'atom']
123
+
section = ['html', 'rss', 'atom']
124
+
taxonomy = ['html', 'rss', 'atom']
125
+
term = ['html', 'rss', 'atom']
126
+
{{< /code-toggle >}}
132
127
133
-
### Step 4
128
+
See [configure outputs][] for more information.
134
129
135
-
Create a template to render the output format. Since Atom feeds are lists, you need to create a list template. Consult the [template lookup order] to find the correct template path:
130
+
Step 4
131
+
: Create a template to render the output format. Since Atom feeds are lists, you need to create a list template. Consult the [template lookup order] to find the correct template path:
136
132
137
-
```text
138
-
layouts/list.atom.atom
139
-
```
133
+
```text
134
+
layouts/list.atom.atom
135
+
```
140
136
141
-
We leave writing the template code as an exercise for you. Aim for a result similar to the [embedded RSS template].
137
+
We leave writing the template code as an exercise for you. Aim for a result similar to the [embedded RSS template][].
142
138
143
139
## List output formats
144
140
145
-
To access output formats, each `Page` object provides two methods: [`OutputFormats`] (for all formats, including the current one) and [`AlternativeOutputFormats`]. Use `AlternativeOutputFormats` to create a link `rel` list within your site's `head` element, as shown below:
141
+
To access output formats, each `Page` object provides two methods: [`OutputFormats`][] (for all formats, including the current one) and [`AlternativeOutputFormats`][]. Use `AlternativeOutputFormats` to create a link `rel` list within your site's `head` element, as shown below:
146
142
147
143
```go-html-template
148
144
{{ range .AlternativeOutputFormats }}
@@ -152,7 +148,7 @@ To access output formats, each `Page` object provides two methods: [`OutputForma
152
148
153
149
## Link to output formats
154
150
155
-
By default, a `Page` object's [`Permalink`] and [`RelPermalink`] methods return the URL of the [primary output format](g), typically `html`. This behavior remains consistent regardless of the template used.
151
+
By default, a `Page` object's [`Permalink`][] and [`RelPermalink`][] methods return the URL of the [primary output format](g), typically `html`. This behavior remains consistent regardless of the template used.
156
152
157
153
For example, in `page.json.json`, you'll see:
158
154
@@ -163,7 +159,7 @@ For example, in `page.json.json`, you'll see:
163
159
{{ end }}
164
160
```
165
161
166
-
To make these methods return the URL of the _current_ template's output format, you must set the [`permalinkable`] setting to `true` for that format.
162
+
To make these methods return the URL of the _current_ template's output format, you must set the [`permalinkable`][] setting to `true` for that format.
167
163
168
164
With `permalinkable` set to true for `json` in the same `page.json.json` template:
169
165
@@ -176,7 +172,7 @@ With `permalinkable` set to true for `json` in the same `page.json.json` templat
176
172
177
173
## Template lookup order
178
174
179
-
Each output format requires a template conforming to the [template lookup order].
175
+
Each output format requires a template conforming to the [template lookup order][].
180
176
181
177
For the highest specificity in the template lookup order, include the page kind, output format, and suffix in the file name:
182
178
@@ -204,7 +200,7 @@ Output format|Template path
204
200
[configure outputs]: /configuration/outputs/
205
201
[configured media types]: /configuration/media-types/
206
202
[default media types]: /configuration/media-types/
0 commit comments