HUGO

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
gohugoio Star
  • About Hugo
    • Overview
    • What is Hugo
    • Hugo features
    • Static site generators
    • Hugo's security model
    • Hugo and the GDPR
    • License
  • Installation
    • Overview
    • macOS
    • Linux
    • Windows
    • BSD
  • Getting started
    • Overview
    • Quick start
    • Basic usage
    • Directory structure
    • Configuration
    • Configure markup
    • Glossary of terms
    • External learning resources
  • Quick reference
    • Overview
    • Emojis
    • Functions
    • Methods
    • Page collections
  • Content management
    • Overview
    • Organization
    • Page bundles
    • Content formats
    • Front matter
    • Build options
    • Page resources
    • Image processing
    • Shortcodes
    • Related content
    • Sections
    • Content types
    • Archetypes
    • Taxonomies
    • Summaries
    • Links and cross references
    • URL management
    • Menus
    • Static files
    • Table of contents
    • Comments
    • Multilingual
    • Markdown attributes
    • Syntax highlighting
    • Diagrams
    • Mathematics
  • Templates
    • Overview
    • Templating
    • Template lookup order
    • Base templates and blocks
    • Single page templates
    • List templates
    • Homepage template
    • Section templates
    • Taxonomy templates
    • Pagination
    • Content view templates
    • Partial templates
    • Shortcode templates
    • Menu templates
    • Data templates
    • RSS templates
    • Sitemap templates
    • Internal templates
    • Custom output formats
    • 404 page
    • Robots.txt
  • Functions
    • Overview
    • cast
    • collections
    • compare
    • crypto
    • data
    • debug
    • diagrams
    • encoding
    • fmt
    • global
    • go template
    • hugo
    • images
    • inflect
    • js
    • lang
    • math
    • openapi3
    • os
    • partials
    • path
    • reflect
    • resources
    • safe
    • strings
    • templates
    • time
    • transform
    • urls
  • Methods
    • Overview
    • Duration
    • Menu
    • Menu entry
    • Page
    • Pages
    • Resource
    • Shortcode
    • Site
    • Taxonomy
    • Time
  • Render hooks
    • Overview
    • Introduction
    • Code blocks
    • Headings
    • Images
    • Links
  • Hugo Modules
    • Overview
    • Configure Hugo modules
    • Use Hugo Modules
    • Theme components
  • Hugo Pipes
    • Overview
    • Introduction
    • Transpile Sass to CSS
    • PostCSS
    • PostProcess
    • JavaScript building
    • Babel
    • Asset minification
    • Concatenating assets
    • Fingerprinting and SRI hashing
    • Resource from string
    • Resource from template
  • CLI
  • Troubleshooting
    • Overview
    • Audit
    • Logging
    • Inspection
    • Deprecation
    • Performance
    • FAQs
  • Developer tools
    • Overview
    • Editor plugins
    • Front-ends
    • Search
    • Migrations
    • Other projects
  • Hosting and deployment
    • Overview
    • Hugo Deploy
    • Deploy with Rclone
    • Deploy with Rsync
    • Host on 21YunBox
    • Host on AWS Amplify
    • Host on Azure Static Web Apps
    • Host on Cloudflare Pages
    • Host on Firebase
    • Host on GitHub Pages
    • Host on GitLab Pages
    • Host on KeyCDN
    • Host on Netlify
    • Host on Render
  • Contribute
    • Overview
    • Development
    • Documentation
    • Themes
  • Maintenance
TEMPLATES

RSS templates

Use the embedded RSS template, or create your own.

Configuration

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:

hugo.
     
outputs:
  home:
  - html
  - rss
  section:
  - html
  - rss
  taxonomy:
  - html
  term:
  - html
[outputs]
  home = ['html', 'rss']
  section = ['html', 'rss']
  taxonomy = ['html']
  term = ['html']
{
   "outputs": {
      "home": [
         "html",
         "rss"
      ],
      "section": [
         "html",
         "rss"
      ],
      "taxonomy": [
         "html"
      ],
      "term": [
         "html"
      ]
   }
}

To disable feed generation for all page kinds:

hugo.
     
disableKinds:
- rss
disableKinds = ['rss']
{
   "disableKinds": [
      "rss"
   ]
}

By default, the number of items in each feed is unlimited. Change this as needed in your site configuration:

hugo.
     
services:
  rss:
    limit: 42
[services]
  [services.rss]
    limit = 42
{
   "services": {
      "rss": {
         "limit": 42
      }
   }
}

Set limit to -1 to generate an unlimited number of items per feed.

The built-in RSS template will render the following values, if present, from your site configuration:

hugo.
     
copyright: © 2023 ABC Widgets, Inc.
params:
  author:
    email: jdoe@example.org
    name: John Doe
copyright = '© 2023 ABC Widgets, Inc.'
[params]
  [params.author]
    email = 'jdoe@example.org'
    name = 'John Doe'
{
   "copyright": "© 2023 ABC Widgets, Inc.",
   "params": {
      "author": {
         "email": "jdoe@example.org",
         "name": "John Doe"
      }
   }
}

Include feed reference

To include a feed reference in the head element of your rendered pages, place this within the head element of your templates:

{{ with .OutputFormats.Get "rss" -}}
  {{ printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
{{ end }}

Hugo will render this to:

<link rel="alternate" type="application/rss+xml" href="https://example.org/index.xml" title="ABC Widgets">

Custom templates

Override Hugo’s embedded RSS template by creating one or more of your own, following the naming conventions as shown in the [template lookup order].

[template lookup order] #template-lookup-order

For example, to use different templates for home, section, taxonomy, and term pages:

layouts/
└── _default/
    ├── home.rss.xml
    ├── section.rss.xml
    ├── taxonomy.rss.xml
    └── term.rss.xml

RSS templates receive the .Page and .Site objects in context.

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).

Example OutputFormat Suffix Template Lookup Order
RSS home rss xml
  1. layouts/index.rss.xml
  2. layouts/home.rss.xml
  3. layouts/rss.xml
  4. layouts/list.rss.xml
  5. layouts/index.xml
  6. layouts/home.xml
  7. layouts/list.xml
  8. layouts/_default/index.rss.xml
  9. layouts/_default/home.rss.xml
  10. layouts/_default/rss.xml
  11. layouts/_default/list.rss.xml
  12. layouts/_default/index.xml
  13. layouts/_default/home.xml
  14. layouts/_default/list.xml
  15. layouts/_internal/_default/rss.xml
Section list for "posts" rss xml
  1. layouts/posts/section.rss.xml
  2. layouts/posts/rss.xml
  3. layouts/posts/list.rss.xml
  4. layouts/posts/section.xml
  5. layouts/posts/list.xml
  6. layouts/section/section.rss.xml
  7. layouts/section/rss.xml
  8. layouts/section/list.rss.xml
  9. layouts/section/section.xml
  10. layouts/section/list.xml
  11. layouts/_default/section.rss.xml
  12. layouts/_default/rss.xml
  13. layouts/_default/list.rss.xml
  14. layouts/_default/section.xml
  15. layouts/_default/list.xml
  16. layouts/_internal/_default/rss.xml
Taxonomy list for "categories" rss xml
  1. layouts/categories/category.terms.rss.xml
  2. layouts/categories/terms.rss.xml
  3. layouts/categories/taxonomy.rss.xml
  4. layouts/categories/rss.xml
  5. layouts/categories/list.rss.xml
  6. layouts/categories/category.terms.xml
  7. layouts/categories/terms.xml
  8. layouts/categories/taxonomy.xml
  9. layouts/categories/list.xml
  10. layouts/category/category.terms.rss.xml
  11. layouts/category/terms.rss.xml
  12. layouts/category/taxonomy.rss.xml
  13. layouts/category/rss.xml
  14. layouts/category/list.rss.xml
  15. layouts/category/category.terms.xml
  16. layouts/category/terms.xml
  17. layouts/category/taxonomy.xml
  18. layouts/category/list.xml
  19. layouts/taxonomy/category.terms.rss.xml
  20. layouts/taxonomy/terms.rss.xml
  21. layouts/taxonomy/taxonomy.rss.xml
  22. layouts/taxonomy/rss.xml
  23. layouts/taxonomy/list.rss.xml
  24. layouts/taxonomy/category.terms.xml
  25. layouts/taxonomy/terms.xml
  26. layouts/taxonomy/taxonomy.xml
  27. layouts/taxonomy/list.xml
  28. layouts/_default/category.terms.rss.xml
  29. layouts/_default/terms.rss.xml
  30. layouts/_default/taxonomy.rss.xml
  31. layouts/_default/rss.xml
  32. layouts/_default/list.rss.xml
  33. layouts/_default/category.terms.xml
  34. layouts/_default/terms.xml
  35. layouts/_default/taxonomy.xml
  36. layouts/_default/list.xml
  37. layouts/_internal/_default/rss.xml
Term list for "categories" rss xml
  1. layouts/categories/term.rss.xml
  2. layouts/categories/category.rss.xml
  3. layouts/categories/taxonomy.rss.xml
  4. layouts/categories/rss.xml
  5. layouts/categories/list.rss.xml
  6. layouts/categories/term.xml
  7. layouts/categories/category.xml
  8. layouts/categories/taxonomy.xml
  9. layouts/categories/list.xml
  10. layouts/term/term.rss.xml
  11. layouts/term/category.rss.xml
  12. layouts/term/taxonomy.rss.xml
  13. layouts/term/rss.xml
  14. layouts/term/list.rss.xml
  15. layouts/term/term.xml
  16. layouts/term/category.xml
  17. layouts/term/taxonomy.xml
  18. layouts/term/list.xml
  19. layouts/taxonomy/term.rss.xml
  20. layouts/taxonomy/category.rss.xml
  21. layouts/taxonomy/taxonomy.rss.xml
  22. layouts/taxonomy/rss.xml
  23. layouts/taxonomy/list.rss.xml
  24. layouts/taxonomy/term.xml
  25. layouts/taxonomy/category.xml
  26. layouts/taxonomy/taxonomy.xml
  27. layouts/taxonomy/list.xml
  28. layouts/category/term.rss.xml
  29. layouts/category/category.rss.xml
  30. layouts/category/taxonomy.rss.xml
  31. layouts/category/rss.xml
  32. layouts/category/list.rss.xml
  33. layouts/category/term.xml
  34. layouts/category/category.xml
  35. layouts/category/taxonomy.xml
  36. layouts/category/list.xml
  37. layouts/_default/term.rss.xml
  38. layouts/_default/category.rss.xml
  39. layouts/_default/taxonomy.rss.xml
  40. layouts/_default/rss.xml
  41. layouts/_default/list.rss.xml
  42. layouts/_default/term.xml
  43. layouts/_default/category.xml
  44. layouts/_default/taxonomy.xml
  45. layouts/_default/list.xml
  46. layouts/_internal/_default/rss.xml

See also

  • Sitemap templates
  • Babel
  • Create your own shortcodes
  • Custom output formats
  • Data templates

On this page

  • Configuration
  • Include feed reference
  • Custom templates
  • Template lookup order
Last updated: February 10, 2024: Create links to referenced embedded templates (ee2069ef)
Improve this page
By the Hugo Authors
Hugo Logo
  • File an Issue
  • Get Help
  • @GoHugoIO
  • @spf13
  • @bepsays

Netlify badge

 

Hugo Sponsors

 

The Hugo logos are copyright © Steve Francia 2013–2024.

The Hugo Gopher is based on an original work by Renée French.

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
  • About Hugo
  • Installation
  • Getting started
  • Quick reference
  • Content management
  • Templates
  • Functions
  • Methods
  • Render hooks
  • Hugo Modules
  • Hugo Pipes
  • CLI
  • Troubleshooting
  • Developer tools
  • Hosting and deployment
  • Contribute
  • Maintenance