Skip to content
← All posts

·

How to add a blog with a sitemap and RSS feed

Add a blog to your product site with a sitemap, RSS feed and structured data. The steps by hand, and what Launchfast already ships in the repository.

Short answer: a blog that search engines can use needs five things beyond the posts: an index page, one URL per post, a sitemap that lists every post, an RSS feed, and structured data on each post that names the author and the dates. All five should read from the same list of posts, so adding a post means adding one file. Launchfast already does this: drop a .mdx file in src/content/blog and the index, sitemap, RSS feed, llms.txt and per-post structured data update on the next build.

Why is adding a blog more than writing posts?

Writing the first post is the easy part. The trouble starts when the pieces drift apart:

  • You publish a post, but it is missing from the sitemap, so Google Search Console reports "Discovered, currently not indexed" or never lists the URL at all.
  • The RSS feed has the old posts only, because it is a hand-edited XML file.
  • Two posts have the same title or no description, so search results show a cut-off or auto-generated snippet.
  • The canonical URL is missing, so /blog/my-post and /blog/my-post/ compete with each other.
  • Posts look the same when shared, because there is no per-post social image.
  • The date in the sitemap never changes when you edit a post, so crawlers have no reason to come back.

Every one of these comes from keeping the post list in more than one place.

How do you add a blog by hand?

  1. Pick a format. Markdown or MDX files in your repository work well: they are versioned, reviewed in pull requests and need no database. A CMS makes sense when non-developers publish.
  2. Define post metadata. Every post needs a title, a description, a publish date, an optional "updated" date and an author. Keep it at the top of the file so one function can read it.
  3. Write one function that lists posts. Read the folder, load each file's metadata, sort newest first. Cache the result, because the files only change when you deploy.
  4. Build the index page at /blog from that list, and the post page at /blog/<slug> that renders one file. Return a 404 for a slug that has no file.
  5. Set the metadata for each post. A unique <title>, a <meta name="description">, a canonical URL, and Open Graph tags with the publish and modified times.
  6. Add structured data. A BlogPosting JSON-LD block with headline, description, datePublished, dateModified, author, publisher and mainEntityOfPage, plus a BreadcrumbList. Both are documented by Google Search Central.
  7. Generate the sitemap from the same list. Serve /sitemap.xml with every post URL and a lastmod that is the updated date when there is one. List it in robots.txt with a Sitemap: line, then submit it in Google Search Console.
  8. Generate an RSS feed. An RSS 2.0 file at /feed.xml with one <item> per post: title, link, a guid, pubDate and description. Escape &, <, > and quotes in the text. Link it from the blog page with <link rel="alternate" type="application/rss+xml"> so feed readers find it.
  9. Give each post a social image. Generate one from the title, so a shared link shows a card rather than a blank preview.
  10. Tell search engines. Google reads the sitemap on its own schedule. Bing and other IndexNow engines accept a ping with the changed URLs.

The traps are steps 7 and 8. A hand-edited sitemap or feed works for the first three posts and silently rots after that. Generate both from the folder.

What does Launchfast already do?

The kit is built on the setup above, and every piece reads one function.

One list of posts. src/lib/blog.ts reads src/content/blog, imports each .mdx file and returns its metadata, newest first. The folder listing is wrapped in "use cache", which Next.js 16 needs for data read from the filesystem at render time. The metadata type is small:

export type PostMeta = {
  title: string;
  description: string;
  date: string;      // YYYY-MM-DD
  updated?: string;  // set when the post changes
  author: string;
};

Pages. src/app/blog/page.tsx is the index, and src/app/blog/[slug]/page.tsx renders one post. The slug is checked against the real file list before anything is imported, and an unknown slug calls notFound(). Each post sets a canonical URL, Open Graph article tags with publishedTime and modifiedTime, and a BlogPosting and breadcrumb block through JsonLd. src/app/blog/[slug]/opengraph-image.tsx draws the social image from the post's title and description.

Sitemap. src/app/sitemap.ts calls getPosts() and adds one entry per post:

...posts.map((p) => page(`/blog/${p.slug}`, 0.6, p.updated ?? p.date)),

Setting updated in a post's metadata changes its lastmod, and src/app/robots.ts points crawlers at /sitemap.xml.

RSS feed. src/app/feed.xml/route.ts builds an RSS 2.0 document from the same list, with the escaping done for you. The blog index declares it as an alternate link, so feed readers can discover it.

For AI assistants. src/app/llms.txt/route.ts lists every post with its description under a "Blog" heading, from the same data, so it can't drift from the site.

IndexNow. After a deploy, npm run indexnow -- /blog/<slug> /blog pings Bing and the other IndexNow engines for just those URLs. It needs the key file in public/ to be live first.

To publish a post, create src/content/blog/<slug>.mdx with the metadata export at the top. Prose goes in plain Markdown. Because it is MDX, write { as &#123; and < as &lt; in text, or put them in backticks.

What does this save you?

You skip building and wiring the post list, the index, the sitemap, the feed, the structured data and the social image, and you skip keeping them in sync later. You still write the posts, and you still submit the sitemap once in Google Search Console. This is not a CMS: there is no editor UI, and posts are published by committing a file. Start from the Launchfast home page, or read how the same approach covers a first Postgres database, taking payments and the SaaS launch checklist.