SEO·Cursor
SEOCursor

Generate a sitemap.xml covering every routeCursor

Without a sitemap, Google has to discover pages only through internal links. On JS-heavy AI-built apps, discovery is slow and unreliable — new pages can wait weeks to be indexed.

rocket_launch

Fixing this in Cursor

Agentic AI code editor built on VSCode

In Next.js App Router, create `app/sitemap.ts` (or `app/sitemap.xml/route.ts`) and Next generates the XML at build. Do not ship a static file — use the dynamic one.

Files to touch in Cursor:

app/sitemap.tsapp/robots.ts

Cursor gotchas:

  • !If you also have a static `/public/sitemap.xml`, the static one wins. Delete it.

Using a different tool? Pick your stack:

The prompt for Cursor

Copy and paste this into your Cursor chat exactly as-is.

Apply these changes to my codebase. Edit the files directly and keep existing formatting:

Add sitemap.xml

1. Create /public/sitemap.xml listing every public route.
2. Wrap each URL in a <url><loc>...</loc></url> entry under <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">.
3. Update /public/robots.txt to add a "Sitemap:" line pointing to the new file.

Why this matters

Googlebot discovers pages in two ways: following links from already-known pages, and reading sitemaps. If your app has few external backlinks (as most new AI-built apps do), link discovery is slow. A sitemap cuts first-indexing time from weeks to days.

Modern SPAs have another discovery problem: routes often only exist after a client-side router runs, which Googlebot may or may not execute. A static `sitemap.xml` bypasses that entirely — every URL is declared upfront in plain XML.

Submitting your sitemap in Google Search Console also unlocks the "Pages" report, which shows exactly which URLs are indexed, which are crawled-but-not-indexed, and why. You cannot debug indexation without this report, and the report does not populate without a submitted sitemap.

How to use this prompt in Cursor

  1. 1. Open your Cursor project.
  2. 2. Copy the prompt above with the copy button.
  3. 3. Paste into the Cursor chat and send.
  4. 4. Review the diff, accept the changes, redeploy.
  5. 5. Verify the fix using the checklist below.

Common mistakes to avoid

  • error_outlineListing hash-based routes (`/app#dashboard`) — Google ignores fragments in sitemaps.
  • error_outlineIncluding URLs that return 404 or 301.
  • error_outlineForgetting to add a `Sitemap: https://…` line to robots.txt.
  • error_outlineShipping a static sitemap that gets stale because nobody regenerates it on deploy.
  • error_outlineListing login, admin, and checkout URLs you do not want indexed.

How to verify the fix worked

  • check_circleVisit `https://yoursite.com/sitemap.xml` in a browser — must return XML, not 404.
  • check_circleRun `curl -s https://yoursite.com/sitemap.xml | xmllint --noout -` — must parse.
  • check_circleSubmit in Google Search Console → Sitemaps — status "Success" within 24 hours.
  • check_circleConfirm `robots.txt` ends with `Sitemap: https://yoursite.com/sitemap.xml`.

Frequently asked questions

Do I need a sitemap if my site has fewer than 20 pages?expand_more
Yes. Even tiny sites benefit — the Search Console Pages report only works with a submitted sitemap, and discovery is still faster.
How often should I regenerate the sitemap?expand_more
On every deploy that adds, removes, or renames a URL. For Next.js `app/sitemap.ts` this happens automatically at build time.
Can a sitemap include URLs from a different domain?expand_more
No. A sitemap at `yoursite.com/sitemap.xml` can only list URLs on `yoursite.com`. Use a sitemap index if you span subdomains.
Does my sitemap need <lastmod>, <changefreq>, or <priority>?expand_more
<lastmod> is useful and Google uses it. <changefreq> and <priority> are largely ignored — skip them.

Want all 34 prompts tailored to your Cursor site?

Pantra scans your site in 10 seconds, detects the stack, and generates the exact prompts that apply — only the ones you actually need.

Scan my site

Related Cursor prompts