Publish an RSS feed
Confirm /rss.xml is on, give every post a date so it appears in the channel, and point CanonicalBaseUrl at your production origin so links resolve.
/rss.xml is wired by UseBlogSite and enabled by default — BlogSiteOptions.EnableRss defaults to true. Two things break a working feed: a post missing date: (silently dropped from the channel), and an unset CanonicalBaseUrl (feed links emit relative URLs that aggregators cannot follow). The feed endpoint ships with the BlogSite template; to emit a feed from a bare AddPennington host or any non-blog content type, see Publish a custom feed from a content service.
Before you begin
- A working BlogSite (see Scaffold a blog with BlogSite if not)
- Posts under
Content/Blog/that parse asBlogSiteFrontMatter - A known production origin (such as
https://blog.example.com).CanonicalBaseUrlneeds the scheme and no trailing slash
Options
Give every post a date:
The /rss.xml feed builds the channel from posts where Date is non-null, ordered by descending date. A post without date: renders normally at its URL but does not appear in the feed. Use ISO-8601 (2024-01-15) so YAML parses the value as a DateTime.
Minimal front matter for a post that appears in the feed:
title: Getting started with Pennington
description: A first-post walkthrough.
date: 2024-01-15
author: Jamie Rivers
tags: [pennington, getting-started]
Set CanonicalBaseUrl to your production origin
The feed prefixes every <link> and <guid> with the canonical base. Use the production scheme and host with no trailing slash:
new BlogSiteOptions
{
CanonicalBaseUrl = "https://blog.example.com",
// ...
}
Result
/rss.xml returns an RSS 2.0 channel listing every dated post, newest first, with absolute URLs:
<rss version="2.0">
<channel>
<title>Jamie's Blog</title>
<link>https://blog.example.com/</link>
<description>Notes on shipping software.</description>
<item>
<title>Getting started with Pennington</title>
<link>https://blog.example.com/blog/getting-started-with-pennington/</link>
<guid>https://blog.example.com/blog/getting-started-with-pennington/</guid>
<pubDate>Mon, 15 Jan 2024 00:00:00 +0000</pubDate>
<description>A first-post walkthrough.</description>
</item>
</channel>
</rss>
Verify
- Run
dotnet runand fetch/rss.xml. Expect a<rss version="2.0">document with one<item>per dated post, newest first - Inspect one
<item>.<link>and<guid>start with theCanonicalBaseUrl, not a relative/blog/...path - Posts without a
date:field are absent from the channel. When an expected post is missing, adddate:to its front matter - After a static build (see Build a static site),
output/rss.xmlexists and carries the same dated items with absoluteCanonicalBaseUrllinks
Related
- How-to: Publish a custom feed from a content service
- Reference: Pennington.BlogSite.BlogSiteOptions
- Reference: Built-in BlogSite routes
- Reference: Front matter key reference