Menu

How to Generate an RSS Feed and sitemap.xml for a Markdown Blog in Node.js
📰

How to Generate an RSS Feed and sitemap.xml for a Markdown Blog in Node.js

DEV Community: node·WaterShow·3 days ago
#ExaxTUqs
#devtonodejs#devto#dev#feed#build
Long article (1545 words) — no AI summary yet.
Reading 0:00
15s threshold

Most Markdown blogs can publish a feed and a sitemap with one small script. The feed lets readers and feed readers find new posts. The sitemap tells search engines which URLs exist and when they changed. Both files come from the same front matter, so they stay in sync when you add a post.

I'll walk through a Node.js script that reads posts from content/posts , skips drafts, sorts by date, and writes feed.xml and sitemap.xml into public/ . Then I'll wire it into the build on Vercel.

1. Front matter for each post

Each post is a Markdown file with a small YAML block at the top. Use ISO dates ( 2025-03-04 ). They are the easiest format to parse reliably.

--- title: "Why my scraper keeps getting blocked" date: 2025-03-04 description: "Rate limits, headers and the three things I check first." slug: scraper-blocked draft: false ---

The post body goes here.

Enter fullscreen mode

Exit fullscreen mode

The slug is optional. If you leave it out, the script uses the file name. updated is also optional.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.