Add a sitemap to Next.js, Astro, SvelteKit, Nuxt, Express or Vite
The same command works on most projects: it recognises the framework, finds the pages and writes a route. Only static sites and single-page apps also need the site's public address.
By
Équipe Maison GR
Product studio, Quebec City
Published
Sources checked
2 min read
Next.js, SvelteKit, Nuxt and Astro with an adapter
These sites answer requests themselves. The command writes the route, a manifest to keep in Git, and the build step.
- anpx maisongr-sitemap init
- bnpm install maisongr-sitemap
Astro without an adapter, adapter-static and nuxt generate
The sitemap is written to the output folder after each build. A static host then serves the XML at /sitemap.xml and the page at /sitemap/.
- anpx maisongr-sitemap init --site https://your.site
- bnpm install --save-dev maisongr-sitemap
Vite and Create React App
Pages are read from your router's table: React Router, Vue Router, TanStack Router and others. Add dynamic routes with --add in the build script.
- anpx maisongr-sitemap init --site https://your.site
- bnpm install --save-dev maisongr-sitemap
Express and Node servers
Run the command in the server's folder. The theme comes from the frontend that server serves. You then list your addresses in the entries() function of sitemap.js and mount the module before any catch-all route: the command prints the exact line.
- anpx maisongr-sitemap init
- bnpm install maisongr-sitemap
An already-built static site
Hand-written HTML, Eleventy, Hugo, Jekyll: the command reads the output folder, including languages and pages marked noindex.
- anpx maisongr-sitemap static dist --site https://your.site
PHP, Python, Ruby or a CMS
The crawl command reads the running site from its home page, as a search engine does, so it only finds pages that are linked. Run it again when content changes.
- anpx maisongr-sitemap crawl http://localhost:8000 --out public --site https://your.site
Check the result
The first command should answer application/xml and the second text/html. On a static host, the second also answers XML until the host's rule is in place. Then submit /sitemap.xml in Search Console and Bing Webmaster Tools.
- acurl -sI http://localhost:3000/sitemap.xml
- bcurl -sI -H "Sec-Fetch-Dest: document" http://localhost:3000/sitemap.xml
To do
The list to keep at hand.
- Run the command at the project's root.
- Do the steps in the report's Next section.
- Give the values for dynamic routes.
- Read the list of pages left out.
- Keep the manifest in Git.
- Submit /sitemap.xml to search engines.
Frequently asked questions
01Why aren't my dynamic pages listed?
A route like /blog/[slug] needs its values: give them in params, or through generateStaticParams with Next.js.
02Should the manifest stay in Git?
Yes. CI builds often clone a partial history, and the manifest keeps the dates.
03Does the package have dependencies?
None at runtime. It needs Node 20.9 or later.
Sources
- maisongr-sitemap — README (2026-11-05)
- Google Search Central — Build and submit a sitemap (2026-11-05)
Related services
→Maison GR
A question about your project? Let's talk.
A senior team member replies within 24 hours with a clear direction.