mdbook-rss-feed
An mdBook preprocessor that generates a beautiful RSS 2.0 feed (and optional Atom) for your book, with HTML previews for each chapter.
Perfect for blogs, documentation sites, or any mdBook that you want to publish.
Features
-
HTML preview in
<description>built from the first paragraphs of each chapter -
Hybrid preview source:
- Prefer chapter body content for the preview
- Fall back to
descriptionin frontmatter when the body is empty or very short
-
Proper XML escaping via the
rsscrate -
Falls back to file modification time if no date in frontmatter
-
Supports
date:in YAML frontmatter (RFC3339 orYYYY-MM-DD) -
Respects
config.book.title,config.book.description, andoutput.html.site-url -
Zero-config, just drop it in
book.toml -
Works with or without YAML frontmatter
-
Optional flag to generate a full-preview
-
Optional paginated feeds: keep
rss.xmlsmall and fast for readers while still exposing older entries viarss2.xml,rss3.xml, etc., so archives stay accessible without bloating the main feed.
Installation
Version Check:
Tested against:
- mdBook v0.4.40 & v0.5.1
- Rust editions 2020 & 2024
Usage
After installing globally, add the following to your mdbook's book.toml:
[]
= "your-title"
= "your-author"
= "your-lang"
= "src"
[]
= ["html"]
# Generate the full chapter as the preview
# full-preview = true
# Enable pagination (rss2.xml, rss3.xml, etc.)
# full-preview = false
# paginated = true # enable pagination
# max-items = 4 # max items per page (0 = unlimited / single feed)
[]
= "https://your-user.github.io/"
renderers = ["html"] ensures the preprocessor only runs for HTML builds.
-
If you omit
title, mdBook will useMy mdbook. -
If you omit
site-url, the default ishttps://example.com. Set this to the public base URL of your site. -
With the example above, the feed would be at:
https://your-user.github.io/rss.xml.- With pagination, if the
max-itemsis less than the total items, the feeds will be split into the necessary number of feeds to meet thatmax-itemsrequirement. - The paginated feeds in the above example would be located at
https://your-user.github.io/rss.xml,https://your-user.github.io/rss2.xml,https://your-user.github.io/rss3.xml, etc.
- With pagination, if the
-
Adding
full-preview = truelets readers view the entire content directly in their feed reader, which improves privacy and reduces tracking by avoiding visits to the website itself.
Pagination
Enable with paginated = true and max-items = N (e.g., 20) in
[preprocessor.rss-feed].
- Collects all .md chapters, sorts by
datein frontmatter (newest first; falls back to file modification time). rss.xmlgets the N newest items only.- Older items go to
rss2.xml,rss3.xml, etc. (e.g., withmax-items = 4,rss.xmlhas top 4 by date). - Keeps the main feed small/fast for readers; full history available in extra files.
To paginate correctly, ensure most chapters have date: in frontmatter (RFC3339
like 2025-12-02T12:00:00Z or simple 2025-12-02). Without dates, sorting uses
file timestamps, which may not reflect publish order.
When switching back to an un-paginated feed, use paginated = false, with
max-items = 0, delete any rss2.xml, rss3.xml files remaining in your
src/ directory, and run mdbook clean before rebuilding. After rebuilding
once with these settings applied, you can remove the paginated = false, and
max-items = 0 if you want.
Frontmatter
Frontmatter is optional. Without it, entries only include the chapter title, book name, and date/time. (varies by RSS reader)
With frontmatter, you can customize those fields and add author and description:
title: Debugging NixOS modules
date:
author: saylesss88
description: This chapter covers debugging NixOS modules, focusing on tracing module
options and evaluating merges.
-
Dates must be parsable (YYYY-MM-DD or RFC3339) to sort accurately.
-
Add dates to all chapters for chronological order; without them, recent file saves win.
-
Using a loader like
mdbook-content-loaderto validate and normalize frontmatter ensures dates are always present and correctly formatted, which makes pagination and chronological ordering in the RSS feed more reliable. (Optional)
How feed preview is generated (default)
The preview is generated from the rendered HTML of the chapter. The crate finds
<p>…</p> blocks and takes the first 2–3 paragraphs, up to 800 characters.
If a chapter starts with non-paragraph content (lists, details blocks, custom markup), the preview starts at the first real paragraph.
To override this, set description in the YAML frontmatter; that text is used
when the body is empty or very short.
-
Default: preview comes from the first few body paragraphs.
-
Fallback: when the body is empty/very short, preview comes from
description.
If you never want to use the fallback, just omit description; the preview will
always come from the body.
Using injected snippets as previews
-
If you use preprocessors like mdbook-content-loader, and mdbook-content-collections to inject intro snippets into your chapters, those snippets are treated just like normal Markdown.
-
Because
mdbook-rss-feedrenders the final chapter Markdown and then finds the first real<p>…</p>blocks, injected paragraphs at the top of the chapter will become the preview text automatically. -
This allows you to maintain small, reusable intro snippets (or per-section summaries) and have them appear in both the book and the RSS feed without any extra configuration.
-
mdbook-content-loadercan enforce typed frontmatter and custom sorting (for example, by a typed date field or other metadata).
mdbook-rss-feed reads the resulting Markdown files and sorts feed items by the
date in frontmatter (falling back to file modification time when missing).
- Combined, you get:
-
Strongly-typed frontmatter (less chance of bad dates or missing fields).
-
Consistent ordering between your book’s index pages and the RSS feed.
-
Cleaner previews when your loader injects well-structured intro snippets at the top of each chapter.
-
Hiding frontmatter in the rendered HTML
mdBook does not parse or strip YAML frontmatter, so the raw block (e.g. any YAML
keys like title:, date:, etc.) appears in the HTML.
To avoid this, you can use:
RSS Button for mdbook header
Your book.toml can accept additional css and js:
= [ "theme/rss-button.css" ]
= [ "theme/rss-buttons.js" ]
In your books theme/ directory, place these two files:
theme/rss-button.css
/* Simple RSS header button */
}
}
/* Optional: orange hover like classic RSS */
}
theme/rss-button.js
document.;
Now you should have a small logo pinned to the top right of your book that leads
to https://your-site/rss.xml