HUGO

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
Star

What's on this Page

  • RSS Template Lookup Order
  • Lookup Order for RSS Templates
  • Configure RSS
  • The Embedded rss.xml
  • Reference your RSS Feed in <head>
TEMPLATES

RSS Templates

Hugo ships with its own RSS 2.0 template that requires almost no configuration, or you can create your own RSS templates.

RSS Template Lookup Order

See Template Lookup Order for the complete reference.

Hugo ships with its own RSS 2.0 template. The embedded template will be sufficient for most use cases.

RSS pages are of the type Page and have all the page variables available to use in the templates.

Section RSS

A section’s RSS will be rendered at /<SECTION>/index.xml (e.g., 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

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
RSS section 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 in 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 in 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

Configure RSS

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 config file.

The following values will also be included in the RSS output if specified:

config.
     
author:
  name: My Name Here
copyright: This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
  International License.
languageCode: en-us
copyright = 'This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.'
languageCode = 'en-us'
[author]
  name = 'My Name Here'

{
   "author": {
      "name": "My Name Here"
   },
   "copyright": "This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.",
   "languageCode": "en-us"
}

The Embedded rss.xml

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>

In your header.html template, you can specify your RSS feed in your <head></head> tag using Hugo’s Output Formats like this:

{{ range .AlternativeOutputFormats -}}
    {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}

If you only want the RSS link, you can query the formats:

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

Either of the two snippets above will generate the below link tag on the site homepage for RSS output:

<link rel="alternate" type="application/rss+xml" href="https://example.com/index.xml" title="Site Title">

We are assuming BaseURL to be https://example.com/ and $.Site.Title to be "Site Title" in this example.

See Also

  • Sitemap Template
  • Custom Output Formats
  • Create Your Own Shortcodes
  • Hugo's Lookup Order
  • Lists of Content in Hugo
  • About Hugo
    • Overview
    • Hugo's Security Model
    • Hugo and GDPR
    • What is Hugo
    • Hugo Features
    • The Benefits of Static
    • License
  • Getting Started
    • Get Started Overview
    • Quick Start
    • Install Hugo
    • Basic Usage
    • Directory Structure
    • Configuration
    • External Learning Resources
  • Hugo Modules
    • Hugo Modules Overview
    • Configure Modules
    • Use Hugo Modules
    • Theme Components
  • Content Management
    • 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 and i18n
    • Syntax Highlighting
  • Templates
    • Templates Overview
    • Introduction
    • Template Lookup Order
    • Custom Output Formats
    • Base Templates and Blocks
    • List Page Templates
    • Homepage Template
    • Section Templates
    • Taxonomy Templates
    • Single Page Templates
    • Content View Templates
    • Data Templates
    • Partial Templates
    • Shortcode Templates
    • Local File Templates
    • 404 Page
    • Menu Templates
    • Pagination
    • RSS Templates
    • Sitemap Template
    • Robots.txt
    • Internal Templates
    • Alternative Templating
    • Template Debugging
  • Functions
    • Functions Quick Reference
    • .AddDate
    • .Format
    • .Get
    • .GetPage
    • .HasMenuCurrent
    • .IsMenuCurrent
    • .Param
    • .Render
    • .RenderString
    • .Scratch
    • .Unix
    • absLangURL
    • absURL
    • after
    • anchorize
    • append
    • apply
    • base64
    • chomp
    • complement
    • cond
    • countrunes
    • countwords
    • default
    • delimit
    • dict
    • echoParam
    • emojify
    • eq
    • errorf and warnf
    • fileExists
    • findRE
    • first
    • float
    • ge
    • getenv
    • group
    • gt
    • hasPrefix
    • highlight
    • hmac
    • htmlEscape
    • htmlUnescape
    • hugo
    • humanize
    • i18n
    • Image Functions
    • in
    • index
    • int
    • intersect
    • isset
    • jsonify
    • lang
    • lang.Merge
    • last
    • le
    • len
    • lower
    • lt
    • markdownify
    • Math
    • md5
    • merge
    • ne
    • now
    • os.Stat
    • partialCached
    • path.Base
    • path.Dir
    • path.Ext
    • path.Join
    • path.Split
    • plainify
    • pluralize
    • print
    • printf
    • println
    • querify
    • range
    • readDir
    • readFile
    • ref
    • reflect.IsMap
    • reflect.IsSlice
    • relLangURL
    • relref
    • relURL
    • replace
    • replaceRE
    • safeCSS
    • safeHTML
    • safeHTMLAttr
    • safeJS
    • safeURL
    • seq
    • sha
    • shuffle
    • singularize
    • site
    • slice
    • slicestr
    • sort
    • split
    • string
    • strings.Count
    • strings.HasSuffix
    • strings.Repeat
    • strings.RuneCount
    • strings.TrimLeft
    • strings.TrimPrefix
    • strings.TrimRight
    • strings.TrimSuffix
    • substr
    • symdiff
    • templates.Exists
    • time
    • time.Format
    • title
    • transform.Unmarshal
    • trim
    • truncate
    • union
    • uniq
    • upper
    • urlize
    • urls.Parse
    • where
    • with
  • Variables
    • Variables Overview
    • Site Variables
    • Page Variables
    • Shortcode Variables
    • Pages Methods
    • Taxonomy Variables
    • File Variables
    • Menu Entry Properties
    • Hugo Variables
    • Git Variables
    • Sitemap Variables
  • Hugo Pipes
    • Hugo Pipes Overview
    • Hugo Pipes Introduction
    • SASS / SCSS
    • PostProcess
    • PostCSS
    • JavaScript Building
    • Babel
    • Asset minification
    • Asset bundling
    • Fingerprinting and SRI
    • Resource from Template
    • Resource from String
  • CLI
  • Troubleshooting
    • Troubleshoot
    • FAQ
    • Build Performance
  • Tools
    • Developer Tools Overview
    • Migrations
    • Starter Kits
    • Frontends
    • Editor Plug-ins
    • Search
    • Other Projects
  • Hosting & Deployment
    • Hosting & Deployment Overview
    • Hugo Deploy
    • Host-Agnostic Deploys with Nanobox
    • Host on AWS Amplify
    • Host on Netlify
    • Host on Render
    • Host on Firebase
    • Host on GitHub
    • Host on GitLab
    • Hosting on KeyCDN
    • Host on Bitbucket
    • Deployment with Rsync
  • Contribute
    • Contribute to Hugo
    • Development
    • Documentation
    • Themes
  • Maintenance
“RSS Templates” was last updated: June 27, 2021: 初始提交 (9b77574)
Improve this page
By the Hugo Authors
Hugo Logo
  • File an Issue
  • Get Help
  • Discuss Source Code
  • @GoHugoIO
  • @spf13
  • @bepsays

Netlify badge

 
 

Hugo Sponsors

Logo for Linode
Logo for eSolia
Logo for Brave
 

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

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

  • News
  • Docs
  • Themes
  • Showcase
  • Community
  • GitHub
  • About Hugo
  • Getting Started
  • Hugo Modules
  • Content Management
  • Templates
  • Functions
  • Variables
  • Hugo Pipes
  • CLI
  • Troubleshooting
  • Tools
  • Hosting & Deployment
  • Contribute
  • Maintenance