Encited

Generate a sitemap from your routes

A sitemap tells Google which pages exist. On a client-rendered app it matters more than usual, because there is often no crawlable path of links from your homepage to every page. Without one, Google finds your homepage and stops.

This prompt reads wherever your routes are defined and writes them into public/sitemap.xml.

When you need this#

  • Search Console shows far fewer pages than your site has.
  • Pages sit in "Discovered, currently not indexed" for weeks.
  • Your navigation is built from JavaScript state rather than real <a href> links.
  • You have no sitemap.xml, or the one you have is out of date.

Skip it if your framework already emits a sitemap at build time. Check /sitemap.xml on your domain first.

The prompt#

I need you to generate a sitemap.xml file and put it inside the public folder.

To do this:
1. Find the place where all my routes are defined (usually in App.tsx, router.tsx, or index.tsx)
2. Go through all the public routes and add them to the sitemap.xml file
3. Exclude any private/dashboard routes from the sitemap
4. Make sure it is valid XML that can be parsed by Google Search Console
5. Use https://YOURDOMAIN.com as the base URL (replace YOURDOMAIN with my actual domain)
6. Also check that all canonical links in the codebase use this same domain

Keep the task scope tight and do not change anything else. Only add the routes to the sitemap.xml file and fix any canonical links if needed.

Replace YOURDOMAIN.com first, and use the same host your canonicals use. Mixing www and non-www between the sitemap and your canonical tags gives Google two versions of every page.

What it changes#

Writes public/sitemap.xml with your public routes, skips dashboard and auth paths, and fixes canonical links that point at the wrong domain.

The limitation#

This produces a snapshot. Every route you add later, and every blog post or product page loaded from a CMS, is missing until someone regenerates the file. Dynamic routes like /blog/:slug cannot be expanded by reading the router at all, since the slugs live in your data.

For a site that keeps growing, use the build-time generator instead. It runs on every build and can fetch slugs from your CMS.

After you run it#

Submit the sitemap in Search Console, then watch coverage rather than assuming. A URL in your sitemap is a suggestion, and Google indexes what it decides is worth indexing. If pages stay unindexed, the Index Rush diagnostics show whether the page was fetched, what came back, and which indexed pages could link to it.

Alternatives#

  • Hand-write the XML. Reasonable under about twenty stable pages.
  • Use a framework plugin. next-sitemap, @nuxtjs/sitemap, and equivalents handle regeneration and are maintained by someone else.
  • Generate it from your CMS. If nearly all your pages come from a CMS, generating the sitemap there is more reliable than reading routes.