summaryrefslogtreecommitdiffstats
path: root/docs/content/en/templates/rss.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/templates/rss.md')
-rw-r--r--docs/content/en/templates/rss.md104
1 files changed, 55 insertions, 49 deletions
diff --git a/docs/content/en/templates/rss.md b/docs/content/en/templates/rss.md
index 90b5155ad..0250e8f54 100644
--- a/docs/content/en/templates/rss.md
+++ b/docs/content/en/templates/rss.md
@@ -1,6 +1,6 @@
---
title: RSS templates
-description: Hugo ships with its own RSS 2.0 template that requires almost no configuration, or you can create your own RSS templates.
+description: Use the built-in RSS template, or create your own.
keywords: [rss, xml, templates]
categories: [templates]
menu:
@@ -11,75 +11,81 @@ weight: 160
toc: true
---
-## RSS template lookup order
+## Configuration
-See [Template Lookup Order](/templates/lookup-order/) for the complete reference.
+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:
-{{% note %}}
-Hugo ships with its own [RSS 2.0 template](#the-embedded-rssxml-template). The embedded template will be sufficient for most use cases.
-{{% /note %}}
-
-RSS pages are of the type `Page` and have all the [page variables](/variables/page/) available to use in the templates.
-
-### Section RSS
-
-A [section’s][section] RSS will be rendered at `/<SECTION>/index.xml` (e.g., [https://spf13.com/project/index.xml](https://spf13.com/project/index.xml)).
-
-Hugo provides the ability for you to define any RSS type you wish and can have different RSS files for each section and taxonomy.
-
-## Lookup order for RSS templates
+{{< code-toggle file=hugo copy=false >}}
+[outputs]
+home = ['html', 'rss']
+section = ['html', 'rss']
+taxonomy = ['html']
+term = ['html']
+{{< /code-toggle >}}
-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`).
+To disable feed generation for all [page kinds]:
-{{< datatable-filtered "output" "layouts" "OutputFormat == RSS" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}
+{{< code-toggle file=hugo copy=false >}}
+disableKinds = ['rss']
+{{< /code-toggle >}}
-## Configure RSS
+By default, the number of items in each feed is unlimited. Change this as needed in your site configuration:
-By default, Hugo will create an unlimited number of RSS entries. You can limit the number of articles included in the built-in RSS templates by assigning a numeric value to `rssLimit:` field in your project's configuration file.
+{{< code-toggle file=hugo copy=false >}}
+[services.rss]
+limit = 42
+{{< /code-toggle >}}
-The following values will also be included in the RSS output if specified:
+Set `limit` to `-1` to generate an unlimited number of items per feed.
-{{< code-toggle file="hugo" >}}
-languageCode = "en-us"
-copyright = "This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License."
+The built-in RSS template will render the following values, if present, from your site configuration:
+{{< code-toggle file=hugo copy=false >}}
+copyright = '© 2023 ABC Widgets, Inc.'
[author]
- name = "My Name Here"
+name = 'John Doe'
+email = 'jdoe@example.org'
{{< /code-toggle >}}
-## The embedded rss.xml template
-
-This is the default RSS template that ships with Hugo:
-
-<https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml>
-
-## Reference your RSS feed in `<head>`
+## Include feed reference
-In your `header.html` template, you can specify your RSS feed in your `<head></head>` tag using Hugo's [Output Formats][Output Formats] like this:
+To include a feed reference in the `head` element of your rendered pages, place this within the `head` element of your templates:
```go-html-template
-{{ range .AlternativeOutputFormats -}}
- {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
-{{ end -}}
+{{ with .OutputFormats.Get "rss" -}}
+ {{ printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
+{{ end }}
```
-If you only want the RSS link, you can query the formats:
+Hugo will render this to:
-```go-html-template
-{{ with .OutputFormats.Get "rss" -}}
- {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
-{{ end -}}
+```html
+<link rel="alternate" type="application/rss+xml" href="https://example.org/index.xml" title="ABC Widgets">
```
-Either of the two snippets above will generate the below `link` tag on the site homepage for RSS output:
+## Custom templates
-```html
-<link rel="alternate" type="application/rss+xml" href="https://example.com/index.xml" title="Site Title">
+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
```
-_We are assuming `BaseURL` to be `https://example.com/` and `$.Site.Title` to be `"Site Title"` in this example._
+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`).
-[embedded]: #the-embedded-rss-xml
-[RSS 2.0]: https://cyber.harvard.edu/rss/rss.html "RSS 2.0 Specification"
-[section]: /content-management/sections/
-[Output Formats]: /templates/output-formats/#link-to-output-formats
+{{< datatable-filtered "output" "layouts" "OutputFormat == rss" "Example" "OutputFormat" "Suffix" "Template Lookup Order" >}}