Feedsby Internet Solutions

Adding RSS to a Static Site: Hugo, Jekyll, Eleventy and Astro

26 tháng 8, 20268 phút đọcNguồn cấp RSS
Adding RSS to a Static Site: Hugo, Jekyll, Eleventy and Astro

Short answer: Static site generators build feeds at build time, just like pages. Hugo creates RSS for the home page and sections out of the box; Jekyll uses the official jekyll-feed plugin to produce an Atom feed; Eleventy uses its official RSS plugin with a small template; and Astro uses the @astrojs/rss package in an endpoint file. In every case, set the site’s absolute base URL, include full dates with time zones, use permanent IDs, add an autodiscovery link to your layout, and validate the output after each deploy.

Static sites are popular with developers, documentation teams and anyone who wants a fast, secure site without a database. Their feeds, however, are often an afterthought: a template copied from a starter theme years ago, a feed that shows relative links, or no feed at all because nobody enabled it. Because a static feed is generated once per build and served as a plain file, it is extremely reliable once it is right. This guide explains how to get it right in the four most common generators, and what to check whichever tool you use.

How feeds work on static sites

On a dynamic platform such as WordPress, the feed is generated on request from the database. On a static site, the generator writes the feed file during the build, exactly like an HTML page, and the web server or CDN serves it as a file. This has consequences:

Hugo

Hugo generates RSS feeds by default for the home page, sections and taxonomy terms, using an internal RSS template. The home page feed is at /index.xml, and each section has its own, such as /posts/index.xml. Key settings:

Most Hugo themes include the autodiscovery link using Hugo’s output formats in the head partial. If your theme does not, add a link rel="alternate" for the RSS output format.

Jekyll

Jekyll’s standard solution is the official jekyll-feed plugin, which GitHub Pages also supports. After adding it to your Gemfile and the plugins list in the configuration, it generates an Atom feed at /feed.xml. Points to know:

Eleventy

Eleventy provides an official RSS plugin, @11ty/eleventy-plugin-rss. Recent versions can generate a feed from a collection through a virtual template with a few lines of configuration, while older setups use a Nunjucks or Liquid template with filters provided by the plugin. The plugin’s filters handle the tricky parts:

Define your production URL in a global data file, use it in the feed template and layout, and add the autodiscovery link to your base layout. Eleventy lets you produce Atom, RSS or JSON Feed; pick one as your main feed.

Astro

Astro uses the @astrojs/rss package. You create an endpoint file, commonly src/pages/rss.xml.js, that returns the result of the package’s rss() function with a title, description, site URL and a list of items built from your content collection. Details:

Checks that apply to every generator

Check Why it matters
Absolute base URL set to production Links and images work in every reader
Permanent IDs that do not change on rebuild No duplicates when you restructure
Dates with times and time zones Correct order and “new” detection
Limited number of items Fast fetching, small files
Autodiscovery link in the layout head Readers find the feed from any page
Correct Content-Type from the host Tools recognise the file as a feed
Validation after each significant change Catches template regressions

Scheduled posts, drafts and rebuilds

Static sites often publish on a schedule: you write a post with a future date, and it appears when the next build runs after that date. If builds only run when you push code, a scheduled post will not appear until the next push. Most hosting platforms allow scheduled builds, for example once an hour or once a day, or you can trigger builds with a cron job. Also make sure drafts and future posts are excluded from feeds in production; most generators do this by default, but custom templates sometimes include everything in a collection.

Other generators and frameworks

The same principles apply to generators not covered above. Gatsby, Next.js, Nuxt, Zola, Pelican, MkDocs and many others either have an official feed plugin or make it easy to write one. When evaluating any option, check that it:

For documentation sites, a feed of release notes or changelog entries is often more valuable than a feed of every page, because readers want to know what changed, not every edit to a reference page.

Moving an existing feed to a new generator

When migrating from WordPress or another generator, the feed URL and item IDs are the two things to protect. Keep the old feed path working, either by generating the feed at the same path or with a permanent 301 redirect, and reuse the old IDs where possible. If the old feed used permalinks as guids and your URLs are unchanged, IDs will match automatically. If URLs change, readers will see the recent items once more as new; that is usually acceptable, but warn your most important consumers, such as partners or newsletter tools.

If you also need to follow sites that do not publish any feed, or combine your static site’s feed with other sources for a partner or a dashboard, our tool, Feeds, can create feeds from pages without RSS and merge several sources into one link with keyword filters. Nothing needs to be installed on the source sites. See the plans.

Related reading

The bottom line

Every major static site generator can publish a clean feed with a small amount of setup: Hugo does it natively, Jekyll and Eleventy through official plugins, Astro through its RSS package. The details that make or break a static feed are the same everywhere: the production base URL, permanent IDs, full dates, a sensible item limit, autodiscovery and regular validation. Get those right once and the feed will serve you quietly for years.

FAQ

Does Hugo create an RSS feed automatically?

Yes. Hugo generates RSS for the home page, sections and taxonomy terms by default, for example at /index.xml. Set baseURL correctly and consider limiting the number of items and customising the template for full text.

How do I add a feed to a Jekyll site?

Add the jekyll-feed plugin, set url in _config.yml, and put {% feed_meta %} in your layout head. The plugin generates an Atom feed at /feed.xml, and GitHub Pages supports it.

Why do links in my static site’s feed not work?

The generator is probably producing relative URLs or using the wrong base URL. Set the production URL in the configuration and make sure links inside content are converted to absolute URLs.

Why doesn’t my scheduled post appear in the feed?

Static feeds are only updated when the site is rebuilt. If no build runs after the post’s date, the post and the feed stay unchanged. Set up scheduled builds on your host.

Should a static site publish RSS, Atom or JSON Feed?

Any of them works. Choose one as the main feed, advertise it with an autodiscovery link, and add others only if your audience needs them.

#CMS#Feed formats#Publishing#RSS
Tạo nguồn cấp đầu tiên của bạn — miễn phí.Nguồn cấp từ mọi trang. Mọi sản phẩm trong mọi danh mục.
Bắt đầu miễn phí
Internet Solutions

Sản phẩm khác từ đội ngũ chúng tôi

Do Internet Solutions phát triển. Hãy thử các sản phẩm khác của chúng tôi — mỗi sản phẩm giúp bạn tiết kiệm thời gian theo một cách riêng.

internet-solutions.net ↗
Tự động đăng mạng xã hộiĐang hoạt động
PostRSS

Bài mới từ nguồn cấp RSS của bạn được tự động đăng lên Facebook, X, LinkedIn, Telegram và hơn 60 mạng khác.

Gói miễn phí · từ 2014Truy cập →
Chat trực tuyến AI cho websiteĐang hoạt động
Talkmio

Website của bạn trả lời khách truy cập 24/7 từ chính nội dung của bạn, bằng ngôn ngữ của họ.

Gói miễn phí · không cần thẻTruy cập →
Trợ lý AIĐang hoạt động
Ask Mio

Trò chuyện, viết code, thiết kế, viết bài và nghiên cứu. Mio chọn mô hình tốt nhất cho từng việc.

Gói miễn phíTruy cập →
Lái tự động AI cho blog và mạng xã hộiĐang hoạt động
AI Blog Autopilot

AI viết bài SEO dài 2.000–3.000 từ và chia sẻ từng bài lên hơn 58 mạng xã hội.

3 bài đầu tiên miễn phíTruy cập →
Kiểm tra sức khỏe websiteĐang hoạt động
Site AI Audit

SEO, tốc độ, SSL, bảo mật và cấu hình email trong một báo cáo, sắp xếp theo việc cần sửa trước.

Lần kiểm tra đầu tiên miễn phíTruy cập →
Thu thập SEO chuyên sâuĐang hoạt động
Site SEO AI Audit

Thu thập SEO toàn diện trên 7 lĩnh vực, gồm cả khả năng hiển thị trong tìm kiếm AI, với cách sửa xếp theo mức tác động.

Lần kiểm tra đầu tiên miễn phíTruy cập →
Phát triển website và SEOĐang hoạt động
Internet Solutions

Website, cửa hàng trực tuyến và hệ thống theo yêu cầu, do đội ngũ của chúng tôi thiết kế, xây dựng và vận hành.

Từ 2011Truy cập →
Feeds
Tổng quan quyền riêng tư

Website này dùng cookie để mang lại trải nghiệm người dùng tốt nhất có thể. Thông tin cookie được lưu trong trình duyệt của bạn và thực hiện các chức năng như nhận ra bạn khi bạn quay lại, giúp đội ngũ chúng tôi hiểu phần nào của website bạn thấy thú vị và hữu ích nhất.