diff --git a/src/content/docs/en/guides/rss.mdx b/src/content/docs/en/guides/rss.mdx index 56d8185026745..385fe9fd51ce9 100644 --- a/src/content/docs/en/guides/rss.mdx +++ b/src/content/docs/en/guides/rss.mdx @@ -214,6 +214,30 @@ export function GET(context) { } ``` +## Removing trailing slashes + +Astro's RSS feed produces links with a trailing slash by default, no matter what value you have configured for `trailingSlash`. This means that your RSS links may not match your post URLs exactly. + +If you have set `trailingSlash: "never"` on your `astro.config.mjs`, set `trailingSlash: false` in the `rss()` helper so that your feed matches your project configuration. + +```ts title="src/pages/rss.xml.js" ins={9} +import rss from '@astrojs/rss'; + +export function GET(context) { + const posts = Object.values(postImportResult); + return rss({ + title: 'Buzz’s Blog', + description: 'A humble Astronaut’s guide to the stars', + site: context.site, + trailingSlash: false, + items: posts.map((post) => ({ + link: post.url, + ...post.frontmatter, + })), + }); +} +``` + ## Adding a stylesheet Style your RSS feed for a more pleasant user experience when viewing the file in your browser.