How to Create RSS Feed from Nuxt Content
By Oktay BozacıPublished: Last updated: 6 min read

RSS feeds provide a simple and reliable way for readers to follow your blog without relying on social media platforms, newsletters, or recommendation algorithms.
If you're building a blog with Nuxt and Nuxt Content, you can generate an RSS feed directly from your Markdown articles. However, instead of providing only article titles, descriptions, and links, you can include the entire article content, allowing subscribers to read your posts directly in their favorite RSS reader.
In this guide, we'll build a full-content RSS feed using Nuxt 4, Nuxt Content v3, Nitro server routes, and Markdown-to-HTML conversion.
What Has Changed in Modern Nuxt?
Older Nuxt applications typically relied on modules such as @nuxtjs/feed and nuxt-content-body-html to generate RSS feeds.
Nuxt Content v3 introduces a collection-based architecture powered by SQL and replaces older content query methods with the queryCollection() API.
With Nitro, we can generate RSS feeds directly through server routes without relying on a dedicated Nuxt RSS module.
This approach gives us full control over feed generation, article selection, caching, and deployment.
1. Install the Required Packages
If you already have a Nuxt project, install the following dependencies:
npm install @nuxt/content feed markdown-it gray-matter
npm install -D @types/markdown-it
Here's what each package does:
@nuxt/content: Manages and queries Markdown articles.feed: Generates RSS 2.0, Atom, and JSON feeds.markdown-it: Converts Markdown into HTML.gray-matter: Removes YAML frontmatter before rendering Markdown.
2. Configure Nuxt
Open your nuxt.config.ts file and register Nuxt Content. We'll also define some reusable website information using runtime configuration.
export default defineNuxtConfig({
modules: ['@nuxt/content'],
runtimeConfig: {
public: {
siteUrl: 'https://example.com',
siteName: 'My Blog',
siteDescription: 'Articles about web development and programming.',
},
},
})
You can override these values using environment variables without modifying your source code.
NUXT_PUBLIC_SITE_URL=https://example.com
NUXT_PUBLIC_SITE_NAME="My Blog"
NUXT_PUBLIC_SITE_DESCRIPTION="Web development and programming articles."
3. Define Your Blog Content Collection
Nuxt Content v3 uses collections to organize content and define its structure.
Create a content.config.ts file in the root directory of your project:
import { defineContentConfig, defineCollection } from '@nuxt/content'
import { z } from 'zod'
export default defineContentConfig({
collections: {
blog: defineCollection({
type: 'page',
source: 'blog/**/*.md',
schema: z.object({
date: z.string(),
author: z.string().optional(),
image: z.string().optional(),
tags: z.array(z.string()).default([]),
draft: z.boolean().default(false),
rawbody: z.string(),
}),
}),
},
})
The most important property here is rawbody.
By default, Nuxt Content stores the parsed article body as an abstract syntax tree (AST). Adding the rawbody field to your collection schema makes the original content available in production.
This allows us to generate HTML without accessing Markdown files directly from the filesystem at runtime.
4. Create a Sample Blog Article
Your project structure should look something like this:
my-nuxt-blog/
├── app/
│ ├── pages/
│ └── app.vue
├── content/
│ └── blog/
│ ├── getting-started-with-nuxt.md
│ └── understanding-vue.md
├── server/
│ ├── routes/
│ │ └── feed.xml.get.ts
│ └── utils/
│ └── markdown.ts
├── content.config.ts
├── nuxt.config.ts
└── package.json
Create a Markdown article at content/blog/getting-started-with-nuxt.md:
---
title: Getting Started with Nuxt
description: Learn how to build modern web applications with Nuxt.
date: '2026-11-29'
author: John Doe
image: /images/nuxt-cover.jpg
tags:
- Nuxt
- Vue
- JavaScript
draft: false
---
## Introduction
Nuxt is a powerful framework for building modern web
applications with Vue.js.
## Why Nuxt?
Nuxt provides several useful features:
- Server-side rendering
- File-based routing
- Static site generation
- Server API routes
- Automatic imports

The RSS feed will use both the article metadata and its complete Markdown content.
5. Convert Markdown to HTML
RSS readers cannot directly render Nuxt Content's internal AST structure. We need to convert the original Markdown into standard HTML.
Create server/utils/markdown.ts:
import MarkdownIt from 'markdown-it'
import matter from 'gray-matter'
export function markdownToHtml(
source: string,
articleUrl: string,
): string {
const md = new MarkdownIt({
html: false,
linkify: true,
typographer: true,
})
const { content } = matter(source)
const resolveUrl = (value: string) => {
try {
return new URL(value, articleUrl).href
} catch {
return value
}
}
const defaultImage = md.renderer.rules.image!
md.renderer.rules.image = (
tokens, idx, options, env, self,
) => {
const token = tokens[idx]
const src = token.attrGet('src')
if (src) {
token.attrSet('src', resolveUrl(src))
}
return defaultImage(tokens, idx, options, env, self)
}
const defaultLink =
md.renderer.rules.link_open ||
((tokens, idx, options, env, self) =>
self.renderToken(tokens, idx, options))
md.renderer.rules.link_open = (
tokens, idx, options, env, self,
) => {
const token = tokens[idx]
const href = token.attrGet('href')
if (href) {
token.attrSet('href', resolveUrl(href))
}
return defaultLink(tokens, idx, options, env, self)
}
return md.render(content)
}
This utility handles Markdown-to-HTML conversion, removes frontmatter, and converts relative links and image paths into absolute URLs.
Absolute URLs are particularly important because RSS readers display your content outside your website.
For example:
<img src="/images/nuxt-cover.jpg">
Becomes:
<img src="https://example.com/images/nuxt-cover.jpg">
Raw HTML is disabled in this example to reduce the risk of injecting unwanted HTML into the feed.
6. Create the RSS Feed Server Route
One of the advantages of modern Nuxt is its built-in Nitro server engine.
Instead of configuring a separate RSS module, we can create a server route that returns an RSS 2.0 XML document.
Create server/routes/feed.xml.get.ts:
import { Feed } from 'feed'
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig(event)
const siteUrl = config.public.siteUrl.replace(/\/+$/, '')
const siteName = config.public.siteName
const siteDescription = config.public.siteDescription
const posts = await queryCollection(event, 'blog')
.where('draft', '=', false)
.order('date', 'DESC')
.limit(30)
.all()
const feed = new Feed({
title: siteName,
description: siteDescription,
id: siteUrl,
link: siteUrl,
language: 'en',
image: `${siteUrl}/favicon.png`,
favicon: `${siteUrl}/favicon.ico`,
copyright: `All rights reserved ${new Date().getFullYear()}, ${siteName}`,
updated: posts.length
? new Date(posts[0].date)
: new Date(),
generator: 'Nuxt',
feedLinks: {
rss2: `${siteUrl}/feed.xml`,
},
author: {
name: siteName,
link: siteUrl,
},
})
for (const post of posts) {
const url = new URL(post.path, siteUrl).href
feed.addItem({
title: post.title,
id: url,
link: url,
description: post.description,
content: markdownToHtml(post.rawbody, url),
date: new Date(post.date),
author: [
{
name: post.author || siteName,
},
],
category: post.tags.map(tag => ({
name: tag,
})),
...(post.image
? {
image: new URL(post.image, siteUrl).href,
}
: {}),
})
}
setResponseHeader(
event,
'Content-Type',
'application/rss+xml; charset=utf-8',
)
return feed.rss2()
})
This server route automatically queries your published articles, converts their Markdown content into HTML, and generates a valid RSS feed.
It also excludes draft articles, orders posts by publication date, includes author information and categories, and limits the feed to the latest 30 articles.
Start your development server:
npm run dev
Your RSS feed is now available at:
http://localhost:3000/feed.xml
7. Understanding Full-Content RSS
A traditional RSS item may contain only a short description of an article.
A full-content RSS feed includes an additional content:encoded element containing the complete HTML content.
The generated XML will have a structure similar to the following:
<item>
<title>Getting Started with Nuxt</title>
<link>
https://example.com/blog/getting-started-with-nuxt
</link>
<description>
Learn how to build modern web applications with Nuxt.
</description>
<content:encoded><![CDATA[
<h2>Introduction</h2>
<p>Nuxt is a powerful framework for building
modern web applications with Vue.js.</p>
<h2>Why Nuxt?</h2>
<ul>
<li>Server-side rendering</li>
<li>File-based routing</li>
<li>Static site generation</li>
</ul>
]]></content:encoded>
</item>
The distinction between description and content:encoded allows RSS readers to display both an article summary and the complete article.
Readers can access your content without having to visit your website, depending on their RSS application's capabilities.
8. Add Automatic RSS Feed Discovery
To help browsers and RSS readers discover your feed automatically, add an alternate link to your website's HTML head.
Update the app section of your nuxt.config.ts:
export default defineNuxtConfig({
app: {
head: {
link: [
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'My Blog RSS Feed',
href: '/feed.xml',
},
],
},
},
})
This generates the following HTML:
<link
rel="alternate"
type="application/rss+xml"
title="My Blog RSS Feed"
href="/feed.xml"
/>
You can also add a visible RSS link to your website's footer or navigation menu.
<template>
<a
href="/feed.xml"
target="_blank"
rel="noopener noreferrer"
>
Subscribe via RSS
</a>
</template>
9. Improve RSS Feed Performance with Caching
Generating an RSS feed on every request is unnecessary, especially for blogs containing hundreds or thousands of articles.
Nuxt route rules allow you to cache server responses directly through Nitro.
Add the following configuration to nuxt.config.ts:
export default defineNuxtConfig({
routeRules: {
'/feed.xml': {
cache: {
maxAge: 3600,
},
},
},
})
With this configuration, the generated RSS feed is cached for one hour.
Caching reduces repeated database queries, Markdown rendering operations, CPU usage, and unnecessary XML generation.
If you publish content frequently, you can reduce the cache duration to 300 or 600 seconds.
10. Generate an RSS Feed for Static Websites
If you deploy your Nuxt application as a static website, you won't have a running Nitro server to generate the RSS feed dynamically.
Fortunately, Nuxt supports prerendering server routes during the build process.
export default defineNuxtConfig({
nitro: {
prerender: {
routes: ['/feed.xml'],
},
},
})
Generate your static website:
npx nuxt generate
The generated RSS feed will be available at:
.output/public/feed.xml
You can then deploy the generated website to a static hosting provider.
Keep in mind that static RSS feeds are updated only when your website is rebuilt and redeployed.
11. Support Atom and JSON Feed
RSS 2.0 is not the only available content syndication format.
The feed package also supports Atom 1.0 and JSON Feed 1.0.
// RSS 2.0
feed.rss2()
// Atom 1.0
feed.atom1()
// JSON Feed 1.0
feed.json1()
You can extract your feed-generation logic into a reusable server utility and expose multiple endpoints.
| Endpoint | Format | Content-Type |
|---|---|---|
| /feed.xml | RSS 2.0 | application/rss+xml |
| /atom.xml | Atom 1.0 | application/atom+xml |
| /feed.json | JSON Feed | application/feed+json |
Providing multiple feed formats is optional, but it gives your readers more flexibility.
12. Migrating from Older Nuxt Versions
If you're upgrading an existing Nuxt Content blog, you'll notice several changes in the modern API.
| Legacy Nuxt Content v1 | Nuxt Content v3 |
|---|---|
| @nuxtjs/feed | Nitro server routes and feed |
| nuxt-content-body-html | Raw content and Markdown rendering |
| $content('posts') | queryCollection(event, 'blog') |
| .fetch() | .all() |
| .sortBy() | .order() |
| post.slug | post.path |
| post.bodyHtml | markdownToHtml(post.rawbody, url) |
| nuxt.config.js feed configuration | server/routes/feed.xml.get.ts |
The modern implementation requires fewer Nuxt-specific modules and offers greater control over feed generation.
If your existing RSS feed is available at /feed, consider preserving that URL through a permanent redirect.
export default defineNuxtConfig({
routeRules: {
'/feed': {
redirect: {
to: '/feed.xml',
statusCode: 301,
},
},
},
})
This helps existing subscribers continue accessing your feed without manually updating their subscriptions.
13. Handling MDC and Custom Vue Components
Nuxt Content supports Markdown Components (MDC), allowing Vue components to be embedded directly inside Markdown articles.
However, RSS readers do not run your Nuxt or Vue application.
Custom components, interactive charts, embedded applications, and other JavaScript-dependent elements will not automatically render using a standard Markdown parser.
For these elements, consider generating static HTML alternatives, using fallback images, replacing interactive components with links, or implementing custom Markdown rendering rules.
Standard Markdown content, including headings, paragraphs, lists, images, links, tables, and code blocks, can be rendered without requiring the Vue runtime.
14. Test and Validate Your RSS Feed
Before publishing your RSS feed, make sure the generated XML is valid and compatible with popular RSS readers.
You can inspect the HTTP response using curl:
curl -I https://example.com/feed.xml
Download the generated XML:
curl -fsSL https://example.com/feed.xml -o feed.xml
Check the XML structure using xmllint, if installed:
xmllint --noout feed.xml
Frequently asked questions
How do I create a full-content RSS feed with Nuxt 4 and Nuxt Content v3?
Create a Nitro server route at `server/routes/feed.xml.get.ts`. Use `queryCollection()` to fetch blog posts, convert their Markdown to HTML, and use the `feed` package to generate RSS 2.0 XML.
Why does the blog collection need a `rawbody` field?
The `rawbody` field makes the original Markdown available in production. The feed route can use it to render the full article as HTML without reading Markdown files from the filesystem at runtime.
How is Markdown prepared for RSS readers?
`gray-matter` strips YAML frontmatter, and `markdown-it` converts the remaining Markdown to HTML. The example disables raw HTML to reduce the risk of injecting unwanted markup into the feed.
Why should links and images in an RSS feed use absolute URLs?
RSS readers display posts outside your website. Resolving relative links and image paths against each article's URL lets readers open those links and load those images.
Which posts does the example RSS feed include?
The example selects up to 30 posts from the `blog` collection where `draft` is `false` and sorts them by date, newest first.
Related posts
What Is a Meta Tag and How to Use It for SEO? (2026 Guide)
What is a meta tag and does it really affect your Google rankings? Find out which tags matter, which are dead, and how to write them correctly.
· 10 min read
What Is a URL Slug and Why Is It Important for SEO
Learn what a URL slug is and how it impacts SEO. This in-depth guide covers best practices, indexing, user experience, CTR, and slug management in modern frameworks.
· 5 min read
How to Create Engaging Titles for SEO: A Complete Guide
Striking blog titles can boost your SEO and clicks. Learn how to create engaging, keyword-rich titles that rank and convert in this complete guide.
· 3 min read


