Feed Subscription NEW
About 1142 words
Overview
The theme can generate RSS 2.0, Atom 1.0 and JSON Feed 1.1 files during a production build, and inject <link rel="alternate"> into the page <head> so that readers and automation tools can discover the subscription URLs automatically.
Unlike the common "one feed per site" setup, feeds are aligned with the collections model and support splitting channels by locale × collection:
.vuepress/dist
feed.xml
atom.xml
feed.json
blog
feed.xml
notes
feed.xml
series
vue3
feed.xml
en
feed.xml
blog
feed.xml
Quick Start
Configure hostname and feed:
import { defineUserConfig } from 'vuepress'
import { plumeTheme } from 'vuepress-theme-plume'
export default defineUserConfig({
theme: plumeTheme({
hostname: 'https://example.com',
feed: true, // only outputs /feed.xml
}),
})hostname is required
Every link in a feed must be absolute. Without hostname the theme skips generation and logs a warning. base must also match the deployment path of the site, otherwise subscription URLs point to the wrong place.
Production build only
Feeds are generated in the onGenerated hook, i.e. only during vuepress build. The dev server (vuepress dev) generates no feed.
Multiple Collections and Locales
Collection channels
Only the global channel is generated by default. Sites with multiple collections can enable perCollection to emit a dedicated channel for every eligible collection:
export default defineUserConfig({
theme: plumeTheme({
hostname: 'https://example.com',
feed: {
perCollection: true,
formats: ['rss', 'atom', 'json'],
},
locales: {
'/': {
collections: [
{ type: 'post', dir: 'blog', title: 'Blog', link: '/blog/' },
{ type: 'post', dir: 'notes', title: 'Notes', link: '/notes/' },
],
},
},
}),
})Output:
| Channel | File | Public URL |
|---|---|---|
| Global | dist/feed.xml | https://example.com/feed.xml |
| Blog | dist/blog/feed.xml | https://example.com/blog/feed.xml |
| Notes | dist/notes/feed.xml | https://example.com/notes/feed.xml |
An article may appear in both the global channel and a collection channel. This is expected.
Collection level switches
feed on a collection controls whether it is included and whether it owns a dedicated channel:
// `doc` collections are excluded by default, `feed: true` opts in explicitly
const doc = { type: 'doc', dir: 'guide', title: 'Guide', sidebar: 'auto', feed: true }// Disable subscriptions for a collection
const post = { type: 'post', dir: 'notes', title: 'Notes', feed: false }feed: true is equivalent to feed: {}: the collection is included in feeds and gets a dedicated channel, without being limited by the theme level perCollection / includeDocCollections.
See collection options for every field.
Series channels
Series (columns) are a second grouping dimension next to collections: collections split by directory, series split by the series frontmatter key. With perSeries enabled, every series emits a channel that sits next to its landing page:
export default defineUserConfig({
theme: plumeTheme({
hostname: 'https://example.com',
feed: {
perSeries: true,
formats: ['rss', 'atom', 'json'],
},
series: true,
}),
})Output:
| Channel | File | Public URL |
|---|---|---|
Series vue3 | dist/series/vue3/feed.xml | https://example.com/series/vue3/feed.xml |
Series vue3 (English) | dist/en/series/vue3/feed.xml | https://example.com/en/series/vue3/feed.xml |
Unlike collection channels, series channels:
- order entries by chapter, not by published date, so a reader can follow the column from part 1;
- are not truncated by default, even when the theme level
feed.limitis set, so subscribers receive the complete table of contents (items[id].feed.limitclamps to 1–200); - are also emitted for a single chapter series; its landing page and the channel home are both the canonical path
/series/<id>/.
The output directory follows the public link of the series: the canonical landing page by default (e.g. /series/vue3/). When the series points at a local page through items[id].link, the feed is written into that directory; items[id].feed.link overrides it on its own.
A series that disabled its landing page (items[id].page: false or a global page: false) and declared none of those links has no home to point at: no channel is generated, and the build log asks you to add a feed.link. An external link counts as unusable as well.
Override the feed of a single series in series.items:
import { defineThemeConfig } from 'vuepress-theme-plume'
export default defineThemeConfig({
series: {
items: {
vue3: {
title: 'Vue 3 in depth',
feed: { title: 'Vue 3 series', limit: 50, formats: ['rss'] },
},
notes: { feed: false }, // disable the channel for this series
handmade: { feed: true }, // opt in while `perSeries` is off
},
},
})feed: true equals feed: {} and opts a single series in when perSeries is disabled.
Subscribe entry
The landing page shows a subscribe button right below the title, pointing at the feed of the series. The button only appears in a production build, where the feed file actually exists.
Locales
Each locale outputs at least one global channel, and the output path follows the locale prefix:
dist/feed.xml → https://example.com/feed.xml
dist/en/feed.xml → https://example.com/en/feed.xmlchannel.link and collection.feed.link are locale relative (e.g. /blog/). The theme prepends the current locale prefix automatically, so do not write /en/ yourself.
Custom filenames and directories
export default defineUserConfig({
theme: plumeTheme({
feed: {
filename: {
rss: 'rss.xml',
atom: 'atom.xml',
json: 'feed.json',
},
channel: {
link: '/subscribe/', // writes the global channel to dist/subscribe/
title: 'Subscribe',
author: { name: 'pengzhanbo', email: 'i@example.com' },
ttl: 60,
},
}
})
})Full Content and Size Trade-offs
content defaults to 'excerpt', which only outputs the summary. Set it to 'full' to output the rendered HTML of the page.
Vue components are not rendered in full mode
The feed content comes from page.contentRendered at build time, where Vue components provided by the theme and vuepress-plugin-md-power (<VPBadge>, <VPCard>, REPL, charts…) are not yet parsed by a browser. Their tags are stripped and only their inner text is kept. Readers should visit the original page for interactive content.
Full mode increases file size significantly. A single channel larger than 10 MB triggers a warning, and you should switch to content: 'excerpt' or lower limit.
Security and Privacy
The following pages and content never enter any feed:
| Case | Behaviour |
|---|---|
Page with password | Excluded |
Matched by encrypt.rules | Excluded |
encrypt.global | The whole feature is disabled with a warning |
frontmatter.draft: true | Excluded |
frontmatter.article: false | Excluded |
frontmatter.feed: false | Excluded (highest priority) |
| Home / post list / tag pages and other non-content pages | Excluded |
::: encrypt snippet | The corresponding tag is removed from the content |
Exclude a single page:
---
title: Internal draft ideas
feed: false
---Override the metadata of a single entry:
---
title: Article title
feed:
title: Title shown in the reader
summary: Custom summary
guid: /custom-id/
---Auto Discovery
During the build, every page that belongs to a generated channel receives the matching link in <head>:
<link rel="alternate" type="application/rss+xml" title="Blog" href="https://example.com/blog/feed.xml">- One link per enabled format;
- Nothing is injected when the page already declares an
alternatelink of the same type; - Set
linkTag: falseto disable it.
Readers only need to paste the site domain into Feedly / Inoreader / NetNewsWire to discover the feeds.
Validation
- RSS / Atom: https://validator.w3.org/feed/
- JSON Feed: https://validator.jsonfeed.org/
Verify determinism locally:
pnpm docs:build
shasum dist/feed.xml dist/atom.xml dist/feed.json
# build again and compare, the results must be identical