A sitemap AI crawlers can find and trust, with the sitemap.xml logo — AIScan cover
A sitemap AI crawlers can find and trust, with the sitemap.xml logo — AIScan cover
AI Readiness

Publish a Sitemap AI Crawlers Can Find: Next.js, Astro, WordPress

Add the robots.txt Sitemap line and a real sitemap on Next.js, Astro, WordPress, Hugo, Docusaurus, Lovable, Vite and Shopify, with lab output. Checks D1, D2.

3 Oct 2026 15 min read
#sitemap#robots-txt#how-to#lovable

This guide covers D2 · Discoverability, D1 · Discoverability — for WordPress, Shopify, Next.js / Vercel, Lovable.

Table of contents

Updated on 30 November 2026: a Lovable and Vite single-page app section, with a Vite 8.4.0 lab and our own site's sitemap routes. Updated on 17 November 2026: per-stack setup for Next.js, Astro, WordPress, Hugo, Docusaurus, Shopify, Webflow and Wix, tested where we could run the stack.

To make a sitemap AI crawlers can find, serve valid XML at /sitemap.xml (or redirect that path to your real file) and add one Sitemap: line with the full https:// URL to robots.txt. Most stacks generate the file for you and leave the robots.txt line to you, which is why 100 of the 849 sites in AIScan's scan database pass robots.txt without declaring a sitemap. The fix takes about 10 minutes per stack, and the sections below give the exact config for each.

Quick summary

If you want to...Do thisCheck it movesTime
Let an agent find the fileAdd Sitemap: https://yourdomain.com/sitemap.xml to robots.txt, full URLD12 min
Pass the sitemap probeServe the file at /sitemap.xml or /sitemap_index.xml, or 301 one of them to your real fileD25 min
Serve a valid fileOne urlset of canonical, absolute URLs, UTF-8, under 50,000 URLs and 50MBnot graded beyond presence10 min
Make dates mean somethinglastmod from the content's last real edit, not the build clocknot graded5 min
Confirm it workednpx aiscan-cli yoursite.com, then read D1 and D2D1, D21 min

Which section is yours: open https://yourdomain.com/robots.txt. If it has no Sitemap: line, find your stack below. If it has one but the path is not /sitemap.xml, read the Astro and WordPress sections, because both generate files at other paths. If /sitemap.xml returns a web page instead of XML, read the Lovable and Vite section.

What the standards say: According to Google Search Central, one sitemap is limited to 50MB uncompressed or 50,000 URLs, Google ignores <priority> and <changefreq>, and it uses <lastmod> only if the value is "consistently and verifiably" accurate. The sitemaps.org protocol asks for the full URL in the robots.txt Sitemap: directive.

What the scan data shows

We grouped the latest site scan for each host in AIScan's database (rubric 2026.08.2, 17 November 2026, 849 hosts, aiscan.site excluded) by the platform the scanner detected.

ResultHostsWhere they cluster
D1 partial: robots.txt returns 200 but has no Sitemap: line100unknown stack 54, WordPress 23 of 211, Next.js 11 of 207, Vue 4 of 6
...of which a sitemap already exists at a probed path41the file is there, only the declaration is missing
D1 fail: robots.txt returns an HTTP error or nothing132129 HTTP errors, 3 no response
D2 fail: nothing at /sitemap.xml or /sitemap_index.xml206150 unknown, 20 Next.js, 18 WordPress
Declares a sitemap in robots.txt, still fails D227 of 617the file lives at another path

Two lessons. The cheapest fix in this post is the robots.txt line: 41 sites already have the sitemap and only need to say so. And 27 sites do the right thing in robots.txt but keep the file at a path the probe does not try. Our earlier corpus study of 782 sites found the same link between the two: 95.3% of sites with a Sitemap: line also had a sitemap at a conventional path, against 44.9% of sites without one.

What AIScan's D1 and D2 check

AIScan's discoverability checks grade two things here. D1 passes when robots.txt returns 200, does not block everything, and declares a sitemap; a file without the line scores partial with the evidence "200 OK, N bytes". D2 passes when /sitemap.xml or /sitemap_index.xml resolves, and it follows a redirect: our own bettershield.ai answers /sitemap.xml with a 301 to /sitemap-index.xml and D2 reports "https://bettershield.ai/sitemap.xml (200 OK)". Both are presence checks. They do not judge whether lastmod is true or every URL resolves; our study Your Sitemap Passes the Check and Still Fails Agents measured that gap.

What we tested

We built each stack locally on 17 November 2026 and fetched the output with curl. Nothing was deployed.

StackVersionWhat it servedThe trap
Next.js16.4.6/robots.txt as text/plain, /sitemap.xml as application/xmlA relative path in sitemap is written out as-is: Sitemap: /blog/sitemap.xml
Astro + @astrojs/sitemap7.4.12 + 3.7.5sitemap-index.xml and sitemap-0.xml, no robots.txt, no lastmodNo file at /sitemap.xml; the redirects option writes an HTML page there
WordPress core7.1.4 (source read)Sitemap: <site>/wp-sitemap.xml added to the virtual robots.txtA physical robots.txt file, or a private site, drops the line
Vite (React + TS template), 30 Nov8.4.0Every path, /sitemap.xml included, as the 200 text/html app shell until public/ holds the filesA missing sitemap looks present: 200, wrong type

Set it up on your stack

Next.js (App Router)

  1. Create app/sitemap.ts that returns an array of { url, lastModified } objects from your content source. Next.js serves it at /sitemap.xml.
  2. Create app/robots.ts and set the sitemap field to an absolute URL.
  3. Run next build and next start, then fetch both files.
import type { MetadataRoute } from 'next'
export default function robots(): MetadataRoute.Robots {
  return {
    rules: { userAgent: '*', allow: '/' },
    sitemap: 'https://yourdomain.com/sitemap.xml',
  }
}

Our build served exactly Sitemap: https://yourdomain.com/sitemap.xml after the rules. Passing an array writes one Sitemap: line per entry, which is how you declare a blog sitemap next to the main one. Next.js does not resolve relative entries, so '/blog/sitemap.xml' comes out as a relative line; always write the host. The Next.js robots file docs show the same object shape. If you also add AI crawler rules, the per-platform training token guide covers the rules array.

Astro

  1. Install the integration with npx astro add sitemap and set site in astro.config.mjs. The build writes sitemap-index.xml and sitemap-0.xml.
  2. Create public/robots.txt yourself. Astro does not generate one. The Astro sitemap integration docs give this content:
User-agent: *
Allow: /

Sitemap: https://yourdomain.com/sitemap-index.xml
  1. Make /sitemap.xml answer with a 301 at the host, not in Astro. On Netlify or Cloudflare Pages, add this line to public/_redirects (see the Cloudflare Pages redirects docs and Netlify's redirect docs):
/sitemap.xml /sitemap-index.xml 301

Do not use Astro's redirects config for this on a static build. In our lab it wrote dist/sitemap.xml as a meta-refresh HTML page, and astro preview served it as 200 text/html. A crawler that asks for XML gets a web page. The integration also leaves out <lastmod> unless you set it with the serialize option or lastmod, so add real dates from your content collection.

WordPress

ThinkRank is the default recommendation here: it manages the sitemap, robots.txt, robots meta, schema and llms.txt from one plugin, so three plugins are not fighting over one file, and it migrates settings from Rank Math, Yoast, All in One SEO and SEOPress so nothing is re-entered. Yoast SEO and Rank Math also write sitemaps (at /sitemap_index.xml, which D2 probes). Core WordPress has built one at /wp-sitemap.xml since 5.5, according to the core team's announcement.

How core adds the line, read from the 7.1.4 source: do_robots() prints User-agent: *, Disallow: /wp-admin/ and Allow: /wp-admin/admin-ajax.php, then runs the robots_txt filter. WP_Sitemaps::add_robots() hooks that filter and appends Sitemap: plus the index URL, but only when the site is public and the wp_sitemaps_enabled filter returns true. So when a WordPress site scores D1 partial, look for one of three causes:

  1. A physical robots.txt file in the web root. The web server serves the file before WordPress runs, so do_robots() never fires and core never adds the line. Add the line to the file by hand, or delete the file and let WordPress or your SEO plugin generate it.
  2. Settings > Reading > "Discourage search engines from indexing this site" is ticked. That sets the site to non-public, which turns off core sitemaps and the line. Untick it on a live site.
  3. A plugin that disabled core sitemaps without adding its own line. Open /robots.txt, then check that your one SEO plugin's sitemap module is on.

For D2 on core alone, /wp-sitemap.xml is not a probed path. Install one SEO plugin with a sitemap at /sitemap_index.xml, or add a 301 from /sitemap.xml to /wp-sitemap.xml at the server.

Hugo

From the Hugo robots.txt docs (we did not run Hugo for this update): set enableRobotsTXT = true. The embedded template prints only User-agent: *, so add layouts/robots.txt:

User-agent: *
Allow: /

Sitemap: {{ "sitemap.xml" | absURL }}

Hugo writes sitemap.xml at the root of a single-language site; on a multilingual site the root file is a sitemap index, so the same line works for both.

Docusaurus

From the Docusaurus sitemap plugin docs (not run): preset-classic already includes the plugin and writes sitemap.xml. Its lastmod option defaults to null, so set it to 'date'. Then write static/robots.txt with the full Sitemap: URL; Docusaurus copies static/ to the build root.

Lovable and Vite single-page apps

Which file you need depends on which Lovable stack your project runs. Lovable's SEO docs (read 30 November 2026) say apps created from 13 May 2026 (22 June on Enterprise plans) use TanStack Start with server-side rendering, and older apps are React + Vite single-page apps. The same page says Lovable "creates a robots.txt with every new project, but not always a sitemap". So check before you assume one exists.

In our scan data (30 November, 894 hosts), 2 of 13 Lovable sites and 4 of 6 Vue sites fail D2, against 18 of 218 WordPress sites. The Vue sites miss twice: 4 of 6 also score D1 partial because robots.txt has no Sitemap: line.

The trap on a Vite single-page app. A single-page app answers every path with index.html, so a missing sitemap does not 404. We built the stock template on 30 November (npm create vite@latest with the react-ts template, Vite 8.4.0, npm run build, then vite preview) and fetched it with curl:

PathBefore adding filesAfter adding files
/robots.txt200 text/html, 453 bytes (the app shell)200 text/plain, 68 bytes
/sitemap.xml200 text/html, 453 bytes (the app shell)200 text/xml, 392 bytes, a 3-URL urlset
/sitemap_index.xml200 text/html200 text/html (still the shell, which is fine once robots.txt names the real file)

vite dev gave the same 200 text/html for both paths before the files existed. A crawler that asks for your sitemap gets a web page with a 200 status. That is the soft-404 problem from our soft-404 explainer, applied to the one file whose whole job is listing your URLs. 7 of the 13 Lovable sites in our data fail E1 (an unknown path answers 200), and 6 of those 7 pass D2. D2's evidence records only the path and the status (<url> (200 OK)), so on a site like that, confirm the content type by hand.

Path A: a React + Vite Lovable project (or any Vite SPA).

  1. Put a real file at public/sitemap.xml. Vite copies public/ to the build root unchanged, and AIScan's Lovable platform page lists the same folder for robots.txt, llms.txt and the .well-known files.
  2. If the route list changes often, generate the file before each build instead of editing it by hand. This is the script we ran, saved as scripts/sitemap.mjs:
// Writes public/sitemap.xml before every build. Add a route here when you add a page.
import { writeFileSync } from "node:fs";
const SITE = "https://yourdomain.com";
const routes = [
  { path: "/", lastmod: "2026-11-30" },
  { path: "/pricing", lastmod: "2026-11-12" },
  { path: "/about", lastmod: "2026-10-02" },
];
const urls = routes
  .map((r) => `  <url>\n    <loc>${SITE}${r.path}</loc>\n    <lastmod>${r.lastmod}</lastmod>\n  </url>`)
  .join("\n");
writeFileSync(
  "public/sitemap.xml",
  `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}\n</urlset>\n`
);
  1. Add "prebuild": "node scripts/sitemap.mjs" to package.json scripts, so npm run build writes the file first.
  2. Write public/robots.txt with the full URL. RFC 9309 §2.2.3 allows the Sitemap: record, and sitemaps.org asks for the absolute URL:
User-agent: *
Allow: /

Sitemap: https://yourdomain.com/sitemap.xml
  1. Use your real domain in both files, never the lovable.app preview address. Lovable's review flags a sitemap that "points to another host" or lists relative URLs.
  2. Publish, then run the two-request test below.

In the Lovable editor you can also ask the chat to "add a sitemap.xml in public/ listing every public route with absolute URLs on my domain". Then read the file it writes against step 5.

Path B: a TanStack Start Lovable project. Here a server route can build the sitemap from your data on every request, which keeps lastmod honest. Our own site, aiscan.site, was built with Lovable on TanStack Start (since 23 November 2026 we host it ourselves, and the routes are the project's own files). This is its real setup, read with curl on 30 November:

URLWhat it returns
/robots.txt200 text/plain, one line Sitemap: https://aiscan.site/sitemap.xml
/sitemap.xml200 application/xml; charset=utf-8, a sitemapindex of four children (pages, docs, use cases, blog)
/sitemap-blog.xml200, 136 URLs, lastmod from each post's last edit (the most common date covers 11 URLs)
/sitemap-pages.xml200, 14 URLs
/sitemap_index.xml, any unknown path404 text/html

The index lives in src/routes/sitemap[.]xml.ts. The brackets escape the dot in TanStack Router's file naming:

export const Route = createFileRoute("/sitemap.xml")({
  server: {
    handlers: {
      GET: async () => {
        const blog = await blogEntries();
        const xml = renderIndex([
          { path: "/sitemap-pages.xml", lastmod: latestLastmod(await corePageEntries(blog)) },
          { path: "/sitemap-blog.xml", lastmod: latestLastmod(blog) },
        ]);
        return new Response(xml, { headers: XML_HEADERS });
      },
    },
  },
});

blogEntries, renderIndex and XML_HEADERS are our own helpers, not a Lovable API. Each one only maps rows to <url> or <sitemap> elements and sets Content-Type: application/xml. The listing above is shortened to two children. Each child (sitemap-blog[.]xml.ts) is a single GET handler returning renderUrlset(...). Because unknown paths return a real 404, the soft-404 trap does not apply on this stack.

To set this up on your own TanStack Start project:

  1. Create src/routes/sitemap[.]xml.ts with a GET server handler, as above.
  2. Build each <loc> from your real domain and your content records, and take lastmod from each record's last edit.
  3. Return the XML with Content-Type: application/xml.
  4. Keep the full Sitemap: URL in robots.txt, whether that file sits in public/ or is a route of its own.

The two-request test for either path:

curl -sI https://yourdomain.com/sitemap.xml | grep -i '^\(HTTP\|content-type\)'
curl -sI https://yourdomain.com/no-such-page.xml | grep -i '^\(HTTP\|content-type\)'

The first must say xml in the content type. If the second also returns 200 text/html, your host has a catch-all, and any file you forget to add will look present. Once the scan shows D2 green, submit the sitemap in Search Console. Lovable's docs say it reads the sitemap "from your live site", so publish first.

Shopify, Webflow and Wix

Hosted platforms generate both files. Shopify serves /sitemap.xml and a default robots.txt that includes the Sitemap: line (15 of 16 Shopify hosts pass D1 in our data), and edits go through the robots.txt.liquid theme template. Keep the line if you customise it. StoreSEO is the default Shopify recommendation for the layer around the sitemap: it builds llms.txt from live products, collections, pages and articles and has an agents.md editor. On Webflow and Wix (4 of 4 Wix hosts pass D1), the setting names vary by plan and editor version, so check the served files with the commands below rather than hunting for a toggle.

Large sites and honest lastmod

Past 50,000 URLs or 50MB, publish a sitemap index that lists one child file per content type, and declare the index. Astro, WordPress core and multilingual Hugo already do this. A build script that stamps today's date on every URL tells crawlers everything changed, and after a few weeks they stop believing any date. Take lastmod from the content record or the last commit that touched the content.

Verify it by scan, then by hand

Fastest route: scan it. Run npx aiscan-cli yoursite.com, or paste your URL at aiscan.site. It is free and needs no account. Read D1 (a pass shows "declares Sitemap") and D2 (the path it resolved).

If you would rather check by hand:

curl -s https://yourdomain.com/robots.txt | grep -i '^sitemap:'
curl -sIL https://yourdomain.com/sitemap.xml | grep -i '^\(HTTP\|content-type\|location\)'
curl -sL https://yourdomain.com/sitemap.xml | head -c 300
SignalPassFail
robots.txt lineSitemap: with a full https:// URLNo line, or a relative path
Status and type200 (after any 301), application/xml or text/xml404, 403, or text/html
BodyStarts with <?xml, then <urlset or <sitemapindexA meta-refresh or HTML page
Dateslastmod differs between URLsEvery URL carries the same date, or none

Common mistakes

  • A relative path in robots.txt, which Next.js will happily print.
  • A physical robots.txt left over on WordPress after installing an SEO plugin.
  • Two plugins each publishing a sitemap.
  • An Astro redirects entry standing in for a real 301.
  • A single-page app answering /sitemap.xml with its HTML shell and a 200.
  • Serving the sitemap from a staging host after a migration.

Related reading: the robots.txt starter for AI crawlers gives a full file to paste the line into, llms.txt vs robots.txt vs sitemap explains what each file is for, and declaring an RSS feed covers the dated feed that complements a sitemap.

Next step

Run the scan on your domain, read D1 and D2, and fix whichever is not green with your stack's section above. Then browse the rest of the fixes in the guides and the discoverability checks. Once the sitemap is sound, IndexNow setup shows how to ping Bing and other engines when a page changes.

Frequently asked questions

Where should the Sitemap line go in robots.txt?

Anywhere in the file, on its own line, as a full absolute URL. It is not tied to a User-agent group. RFC 9309 leaves it outside the standard, but major crawlers read it, and sitemaps.org asks for the full URL.

AIScan says D1 is partial with "200 OK, N bytes". What is missing?

The Sitemap: line. Your robots.txt loads and does not block everything, but it declares no sitemap. Add one line with the full https:// URL of your sitemap or sitemap index and re-scan.

D2 failed but my sitemap exists. Why?

D2 probes /sitemap.xml and /sitemap_index.xml and follows redirects. A file only at another path, such as Astro's /sitemap-index.xml or WordPress core's /wp-sitemap.xml, is missed. Add a 301 from /sitemap.xml to the real file and keep the robots.txt line.

My WordPress robots.txt has no Sitemap line even though core makes a sitemap. Why?

Usually a physical robots.txt file in the web root, which the server serves before WordPress runs. The other causes are the Discourage search engines setting under Settings > Reading, or a plugin that turned off core sitemaps without adding its own line.

My /sitemap.xml returns 200 but the body is an HTML page. What is wrong?

Either a catch-all route is answering unknown paths, or a static redirect page is standing in for the file, which is what Astro's redirects option produces. Serve real XML at the path, or make the host answer with a 301 to the real sitemap.

Does Next.js accept a relative path in robots.ts?

It accepts it and prints it unchanged, which gives you a relative Sitemap line that crawlers may ignore. Next.js 16.4.6 did exactly that in our test. Always write the full URL, and pass an array if you have more than one sitemap.

Do I still need a sitemap if I have llms.txt?

Yes. llms.txt is a curated reading list for models, while the sitemap is the complete URL inventory crawlers use for discovery. They answer different questions.

Should I add priority and changefreq?

No. Google's sitemap documentation says it ignores both. Spend the effort on lastmod dates that reflect real content edits instead.

My Lovable site's /sitemap.xml returns 200 but Search Console says it is HTML. Why?

On a React + Vite Lovable project with no sitemap file, every path returns the app's index.html with a 200 status, so /sitemap.xml looks present but is a web page. Add a real file at public/sitemap.xml with absolute URLs on your own domain, publish, and check that curl -sI shows an xml content type.

Lovable's review says my sitemap points to another host. What is wrong?

The sitemap lists URLs on the lovable.app preview address instead of your custom domain. Regenerate it with your real domain in every <loc>, update the Sitemap: line in public/robots.txt to the same domain, publish, and submit the new sitemap in Search Console.

I added public/sitemap.xml to my Vite app but /sitemap.xml still shows the app. Why?

The file was not in the build that is being served. Vite copies public/ into dist/ only when you run npm run build, so rebuild and redeploy, then confirm dist/sitemap.xml exists. In our Vite 8.4.0 test the same path changed from 200 text/html to 200 text/xml after a rebuild.

M Asif Rahman

About the author

Entrepreneur, curious about AI

I have been building companies for a long time, and lately most of my curiosity goes to AI. AIScan is a small personal project I built on a flight from Dubai to Narita. I use it to understand how ready the web is for AI agents, and I share what the scans teach me.

Related guides

Browse every guide by check and platform