Skip to content

A next-sitemap alternative: when to switch, and how

next-sitemap is still a good tool, and Next.js can also produce a sitemap on its own. Switching only makes sense for a specific need: true modification dates, or a readable page at the sitemap's address. Here's how to decide.

By

Équipe Maison GR

Product studio, Quebec City

Published

Sources checked

2 min read

01

The three options

maisongr-sitemap is our package, so read this comparison with that in mind.

  • aNext.js's app/sitemap.ts file: no dependency. You write the list of pages and their dates yourself.
  • bnext-sitemap: runs after the build, writes files to public/ and can produce robots.txt.
  • cmaisongr-sitemap: a route that answers crawlers with XML and people with a page in the site's design. It finds the pages in your route files.
02

When to keep what you have

If Search Console accepts your sitemap and nobody opens it, nothing forces you to change. A small site with stable pages is well served by app/sitemap.ts.

03

Reasons to switch

Google says it uses lastmod if the value is consistently and verifiably accurate. A date that moves on every build doesn't meet that condition.

  • aDates: next-sitemap adds the build date by default. maisongr-sitemap uses the last commit that changed each page.
  • bReading: at /sitemap.xml, a person sees a page with links and a filter instead of raw XML.
  • cLanguages: hreflang alternates are read from your routes and config.
  • dFiles: a route serves the sitemap, so there are no generated files to ignore in Git.
04

Migrating from next-sitemap

One command does most of the work. It moves the files to .sitemap-replaced/, takes out the postbuild step and keeps your siteUrl address.

  • anpx maisongr-sitemap init --replace
  • bnpm install maisongr-sitemap
  • cnpm uninstall next-sitemap
05

What to carry over by hand

Rules written in code aren't converted. Read your old config in .sitemap-replaced/ and move them into the route: exclude for paths to leave out, params or entries for dynamic pages. Then check that robots.txt still names /sitemap.xml, especially if next-sitemap generated it.

To do

The list to keep at hand.

  • Note the exclude and transform rules in your config.
  • Run npx maisongr-sitemap init with no flag to see what blocks it.
  • Run the migration with --replace.
  • Move rules written in code into the route.
  • Check that robots.txt names /sitemap.xml.
  • Delete .sitemap-replaced/ once you've checked the result.

Frequently asked questions

01Does next-sitemap work with the App Router?

Yes. It runs after the build and writes its files to public/, whichever router you use.

02Does the migration delete my files?

No. They go to .sitemap-replaced/, and the package stays installed until you run npm uninstall.

03Are my exclude rules carried over?

No. Rules written in code move by hand, into the route's options.

Related services

→Maison GR

A question about your project? Let's talk.

A senior team member replies within 24 hours with a clear direction.