2019-10-21 04:22:28 -04:00
---
2023-07-29 05:15:54 -04:00
title: RSS templates
2023-09-24 05:54:45 -04:00
description: Use the built-in RSS template, or create your own.
2019-10-21 04:22:28 -04:00
categories: [templates]
2023-12-04 09:14:18 -05:00
keywords: [rss,xml,templates]
2019-10-21 04:22:28 -04:00
menu:
docs:
2023-05-22 10:43:12 -04:00
parent: templates
2023-07-29 05:15:54 -04:00
weight: 160
weight: 160
2019-10-21 04:22:28 -04:00
toc: true
---
2023-09-24 05:54:45 -04:00
## Configuration
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
By default, when you build your site, Hugo generates RSS feeds for home, section, taxonomy, and term pages. Control feed generation in your site configuration. For example, to generate feeds for home and section pages, but not for taxonomy and term pages:
2019-10-21 04:22:28 -04:00
2023-12-04 09:14:18 -05:00
{{< code-toggle file = hugo > }}
2023-09-24 05:54:45 -04:00
[outputs]
home = ['html', 'rss']
section = ['html', 'rss']
taxonomy = ['html']
term = ['html']
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
To disable feed generation for all [page kinds]:
2019-10-21 04:22:28 -04:00
2023-12-04 09:14:18 -05:00
{{< code-toggle file = hugo > }}
2023-09-24 05:54:45 -04:00
disableKinds = ['rss']
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
By default, the number of items in each feed is unlimited. Change this as needed in your site configuration:
2019-10-21 04:22:28 -04:00
2023-12-04 09:14:18 -05:00
{{< code-toggle file = hugo > }}
2023-09-24 05:54:45 -04:00
[services.rss]
limit = 42
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
Set `limit` to `-1` to generate an unlimited number of items per feed.
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
The built-in RSS template will render the following values, if present, from your site configuration:
2019-10-21 04:22:28 -04:00
2023-12-04 09:14:18 -05:00
{{< code-toggle file = hugo > }}
2023-09-24 05:54:45 -04:00
copyright = '© 2023 ABC Widgets, Inc.'
2023-12-04 09:14:18 -05:00
[params.author]
2023-09-24 05:54:45 -04:00
name = 'John Doe'
email = 'jdoe@example.org'
2021-04-20 14:21:45 -04:00
{{< / code-toggle > }}
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
## Include feed reference
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
To include a feed reference in the `head` element of your rendered pages, place this within the `head` element of your templates:
2019-10-21 04:22:28 -04:00
```go-html-template
2023-09-24 05:54:45 -04:00
{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
{{ end }}
2019-10-21 04:22:28 -04:00
```
2023-09-24 05:54:45 -04:00
Hugo will render this to:
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
```html
< link rel = "alternate" type = "application/rss+xml" href = "https://example.org/index.xml" title = "ABC Widgets" >
2019-10-21 04:22:28 -04:00
```
2023-09-24 05:54:45 -04:00
## Custom templates
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
Override Hugo's [built-in RSS template] by creating one or more of your own, following the naming conventions as shown in the [template lookup order table].
For example, to use different templates for home, section, taxonomy, and term pages:
```text
layouts/
└── _default/
├── home.rss.xml
├── section.rss.xml
├── taxonomy.rss.xml
└── term.rss.xml
2019-10-21 04:22:28 -04:00
```
2023-09-24 05:54:45 -04:00
RSS templates receive the `.Page` and `.Site` objects in context.
[built-in RSS template]: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml
[page kinds]: /getting-started/glossary/#page-kind
[template lookup order table]: #template -lookup-order
## Template lookup order
The table below shows the RSS template lookup order for the different page kinds. The first listing shows the lookup order when running with a theme (`demoTheme`).
2019-10-21 04:22:28 -04:00
2023-09-24 05:54:45 -04:00
{{< datatable-filtered " output " " layouts " " OutputFormat = = rss " " Example " " OutputFormat " " Suffix " " Template Lookup Order " > }}