Check 03.05 · Crawling

Declare sitemaps in robots.txt

Add a valid Sitemap line to robots.txt for each host, check that it returns 200 and set it up on WordPress, Shopify, Magento or Next.js.

Priority
Critical
Difficulty
Easy
Estimated time
15 to 30 min
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

The Sitemap: line in robots.txt tells every crawler where to find the list of your URLs, with no need to declare it tool by tool. This check consists of adding one line per sitemap or sitemap index, with an absolute URL that returns 200, on every host of the site. Expected result: curl https://example.com/robots.txt shows at least one Sitemap: https://example.com/…xml line, and every declared URL returns a valid XML file.

Why it matters

The sitemap field is part of the sitemaps protocol (sitemaps.org), and Google, Bing and the other major search engines read it. It is the only way of declaring a sitemap that works for every crawler at once, with no account or tool:

  • Google and Bing recommend both routes: submission in Search Console and Bing Webmaster Tools, and the Sitemap: line in robots.txt. Bing says it generally rereads a known sitemap at least once a day.
  • Other crawlers that read robots.txt, regional search engines or generative engine crawlers, can use it to discover your pages. No AI vendor commits to doing so: it is a possibility, not a guarantee.
  • The old “ping” is gone. Bing ended anonymous sitemap submission by URL in 2022, and Google retired its ping endpoint at the end of 2023. What remains is submission in the tools, robots.txt and, for individual updates, IndexNow (opens in a new tab).

The writing rules are simple but strict:

  • Absolute URL, protocol and host included. Google guesses neither http nor https, nor whether www is present.
  • Outside any group: the line does not depend on any User-agent; crawlers ignore it when they group rules. Put it at the end of the file for readability.
  • Several lines are allowed: one per sitemap or, more simply, a single one pointing to the sitemap index.
  • Another host is allowed. Google accepts a robots.txt pointing to a sitemap hosted elsewhere, provided that sitemap only lists URLs of the site it is declared for.

The declaration is a hint: it helps discovery, it forces neither crawling nor indexing.

What it improves

  • Page discovery Every crawler that reads robots.txt finds the sitemap, including those you have no account with.
  • New sites and new sections Pages that are still poorly linked are spotted sooner.
  • Generative engines A possible effect, but not documented by the vendors. A discovered page is not necessarily cited.
  • Maintenance A single line pointing to an index automatically keeps up with new sitemaps.
  • Rankings No effect.

How to check

List the declared lines and test each URL:

curl -s https://example.com/robots.txt | tr -d '\r' | grep -i '^sitemap:' \
  | sed -E 's/^[Ss][Ii][Tt][Ee][Mm][Aa][Pp]:[[:space:]]*//' \
  | while read -r url; do
      printf '%s  %s\n' "$(curl -s -o /dev/null -w '%{http_code} %{content_type}' "$url")" "$url"
    done

Expected result:

200 application/xml; charset=UTF-8  https://example.com/sitemap_index.xml

text/xml is also accepted. To fix: no line, a 301 or 404 status, a relative URL (Sitemap: /sitemap.xml), a protocol or host different from the site's canonical version, a text/html type.

Then check the content of the declared file:

curl -s --compressed https://example.com/sitemap_index.xml | head -c 400

It must start with <?xml followed by <sitemapindex or <urlset. Run the test again on every host that has its own content (blog.example.com, shop.example.com) and on every language version served on a separate domain.

The robots.txt declaration gives you no monitoring. To see read errors and the number of URLs taken into account, also submit the index in the Search Console Sitemaps report and in the Sitemaps section of Bing Webmaster Tools.

How to implement

Before you start

Choose the form according to the site's structure:

Situation Lines to write
A single sitemap Sitemap: https://example.com/sitemap.xml
Several sitemaps grouped in an index a single line pointing to the index
Several sitemaps without an index one line per file
Languages in subfolders, one sitemap per language one line pointing to the index, or one line per language
Subdomains each subdomain declares its sitemap in its own robots.txt

Typical end of file:

User-agent: *
Disallow: /admin/
Disallow: /panier/

Sitemap: https://example.com/sitemap_index.xml

Example with several files:

Sitemap: https://example.com/sitemaps/pages.xml
Sitemap: https://example.com/sitemaps/produits.xml
Sitemap: https://example.com/sitemaps/articles.xml

Only declare sitemaps that exist and that you maintain. A sitemap that has been deleted but is still declared causes fetch errors in the search engines' tools. The content of the sitemaps themselves is covered in Generate the XML sitemap automatically (opens in a new tab).

Apache

Versions Apache 2.4.

Add the line to the robots.txt file in the DocumentRoot. Make sure the sitemap is served with an XML type; if it is a static file, add this to .htaccess if needed:

<FilesMatch "\.xml$">
    ForceType "application/xml; charset=utf-8"
</FilesMatch>

Nginx

Versions Nginx 1.18 and later.

The file is edited in the root directory. The application/xml type is mapped to the .xml extension in mime.types: nothing to configure for a static file. If the sitemap is generated by the application behind proxy_pass, the application must send the Content-Type header.

Cloudflare

Versions Cloudflare dashboard, all plans, November 2026.

If Cloudflare's managed robots.txt is on, Cloudflare prepends its block to the file and keeps your lines, Sitemap included. If there is no file at the origin, Cloudflare creates one: check that the Sitemap line is in it, and otherwise create a robots.txt at the origin that contains it. After a change, purge /robots.txt in Caching > Configuration.

AWS

Versions Amazon S3 and CloudFront, AWS CLI v2, November 2026.

On a static S3 site behind CloudFront, update the file and then invalidate it:

aws s3 cp robots.txt s3://BUCKET_NAME/robots.txt --content-type "text/plain; charset=utf-8"
aws s3 cp sitemap.xml s3://BUCKET_NAME/sitemap.xml --content-type "application/xml; charset=utf-8"
aws cloudfront create-invalidation --distribution-id DISTRIBUTION_ID --paths "/robots.txt" "/sitemap.xml"

Plesk

Versions Plesk Obsidian 18.0.

Websites & Domains > your domain > Files, httpdocs folder: open robots.txt in the editor and add the line at the end of the file.

cPanel

Versions cPanel & WHM 110 and later, up to version 138 (Jupiter theme).

Files > File Manager, public_html folder, Edit on robots.txt, add the line and save.

Shared hosting

Edit robots.txt at the web root over SFTP or with the file manager. If a CMS generates the sitemap, read the section that covers it: it sometimes adds the line itself, provided there is no physical file.

Vercel

Versions Vercel platform, all plans, November 2026.

Add the line to the public/robots.txt file, or let the framework generate both files (see Next.js, Nuxt, Astro). Redeploy.

Netlify

Versions Netlify platform, all plans, November 2026.

Same principle: line added to the robots.txt in the publish directory, then redeploy.

WordPress

Versions WordPress 6.4 to 7.1; Yoast SEO 22 to 28, Rank Math 1.0.

  • Without an SEO plugin: WordPress enables its native sitemap (/wp-sitemap.xml) and adds the Sitemap line to its virtual robots.txt itself. Both are disabled if the “Discourage search engines from indexing this site” checkbox is ticked.
  • Yoast SEO: when its sitemaps are on, Yoast replaces the native sitemap and adds Sitemap: https://example.com/sitemap_index.xml to the virtual robots.txt.
  • Rank Math: the sitemap is also served at /sitemap_index.xml; check that the line is present in the plugin's robots.txt editor and add it if it is missing.
  • Physical file: as soon as a robots.txt exists at the root, no line is added automatically any more. Write it yourself, and update it if you change SEO plugin: the sitemap URL changes with it.

Shopify

Versions Shopify admin, all plans, November 2026.

Automatic: Shopify's robots.txt declares https://example.com/sitemap.xml, the store's sitemap index. If you customize robots.txt.liquid, keep the {%- if group.sitemap != blank -%}{{ group.sitemap }}{%- endif -%} block, which produces this line. For a store on several international domains, each domain serves its own robots.txt and its own sitemap.

PrestaShop

Versions PrestaShop 8 and 9 (up to 9.2), Google sitemap module (gsitemap) 4.

The “Google sitemap” module generates an index named after the store ID (1_index_sitemap.xml) at the root. PrestaShop's robots.txt generator adds the Sitemap line pointing to this file if it exists at generation time. So generate the sitemap first, then regenerate robots.txt in Shop Parameters > Traffic & SEO.

Magento

Versions Magento Open Source and Adobe Commerce 2.4.7 to 2.4.9.

In Stores > Settings > Configuration > Catalog > XML Sitemap, Search Engine Submission Settings section, set Enable Submission to Robots.txt to Yes for the relevant store view, then save and flush the cache. The sitemap must already exist in Marketing > SEO & Search > Site Map.

Drupal

Versions Drupal 10 and 11, Simple XML Sitemap module 4.

The Simple XML Sitemap module publishes /sitemap.xml, but the web/robots.txt file shipped with Drupal does not declare it. Add the line at the end of the file, or through the RobotsTxt module if you edit the file in the admin interface. If robots.txt is not excluded from Composer scaffolding, your addition will disappear at the next core update.

Wix

Versions Wix editor and Wix Studio, all plans, November 2026.

Wix generates the sitemap and declares it in its robots.txt. If you add rules with the robots.txt editor, do not delete the Sitemap line. Squarespace works the same way, with no editable file.

Webflow

Versions Webflow site settings, all plans, November 2026.

Turn on automatic sitemap generation in Site settings > SEO. If you enter a custom robots.txt in the same tab, add the Sitemap: https://example.com/sitemap.xml line yourself, then republish the site.

Laravel

Versions Laravel 10 to 13.

In a static public/robots.txt file, hard-code the line. If robots.txt is generated by a route, build the URL from the configuration so that it follows the environment:

{{-- resources/views/robots.blade.php --}}
User-agent: *
Disallow: /admin/

Sitemap: {{ url('sitemap.xml') }}

url() relies on APP_URL and on the request: check in production that the line really shows https:// and the canonical host.

Next.js

Versions Next.js 13 to 16 (App Router from 13.3, and Pages Router).

App Router

In app/robots.ts (Next.js 13.3 and later), the sitemap key accepts a string or an array:

// app/robots.ts
import type { MetadataRoute } from 'next'

export default function robots(): MetadataRoute.Robots {
  return {
    rules: { userAgent: '*', disallow: ['/admin/', '/panier/'] },
    sitemap: [
      'https://example.com/sitemap.xml',
      'https://example.com/produits/sitemap/0.xml',
      'https://example.com/produits/sitemap/1.xml',
    ],
  }
}

The sitemaps produced by generateSitemaps are served at /…/sitemap/[id].xml (in development as in production since Next.js 15): declare each one, or create an index.

Pages Router

The robots.ts and sitemap.ts metadata files only exist in the App Router. Write the line in a static public/robots.txt file, with the sitemap's absolute URL, or let the tool that generates your sitemaps produce this file as well:

User-agent: *
Disallow: /admin/

Sitemap: https://example.com/sitemap.xml

Nuxt

Versions Nuxt 3 and 4; @nuxtjs/robots 5 to 7 (version 7 requires Nuxt 4.6 or later) and @nuxtjs/sitemap 7 to 9.

With the @nuxtjs/robots and @nuxtjs/sitemap modules, set the site URL (site: { url: 'https://example.com' } in nuxt.config.ts) and check the line produced in /robots.txt. You can force it in the robots module configuration with the sitemap key.

Astro

Versions Astro 4 to 7, @astrojs/sitemap 3 integration.

The @astrojs/sitemap integration produces sitemap-index.xml, but no robots.txt. Generate it with an endpoint that reuses the site URL:

// src/pages/robots.txt.ts
import type { APIRoute } from 'astro'

export const GET: APIRoute = ({ site }) => {
  const sitemapUrl = new URL('sitemap-index.xml', site)

  return new Response(`User-agent: *\nDisallow: /admin/\n\nSitemap: ${sitemapUrl.href}\n`, {
    headers: { 'Content-Type': 'text/plain; charset=utf-8' },
  })
}

The site value must be set in astro.config.mjs.

Common mistakes

  • Relative URL: Sitemap: /sitemap.xml is not valid; the URL must be complete.
  • Wrong protocol or wrong host: http:// or www. when the canonical site uses https:// without www. Google does not correct it.
  • Line left behind after a plugin change: switching from WordPress's native sitemap to Yoast changes the URL (/wp-sitemap.xml to /sitemap_index.xml).
  • Staging sitemap declared in production, or the other way round, through a file copied from one environment to another.
  • Declaring dozens of files by hand when an index is enough and updates itself.
  • Thinking the line replaces submission: it complements it. Also submit the index in Search Console and Bing Webmaster Tools to track errors (see Submit sitemaps to Google and Bing (opens in a new tab)).
  • Still using ping URLs: they no longer work at Google or Bing.

Frequently asked questions

Should the sitemap be declared in robots.txt if it has been submitted to Search Console?

Yes, the two complement each other. Submission in Search Console and Bing Webmaster Tools lets you track errors and indexing. The Sitemap line in robots.txt makes the sitemap discoverable by every crawler that reads this file, including those you have no account with. It costs a single line and needs no maintenance if it points to an index.

Can robots.txt contain several Sitemap lines?

Yes, robots.txt accepts as many Sitemap lines as needed, each with an absolute URL. When files multiply, a single line pointing to a sitemap index is simpler: the index lists the files, and a new sitemap is added to it without touching robots.txt. The Sitemap line does not depend on any User-agent group, so its position in the file does not matter.

Can the sitemap URL in robots.txt be relative?

No, the URL declared in robots.txt must be absolute, with the protocol and the host: Sitemap: https://example.com/sitemap.xml. Google does not infer the http or https, www or non-www variants from a relative path. Use exactly the host and protocol of the site's canonical version, then check that the URL returns 200 with an XML type.

Do AI crawlers read the sitemap declared in robots.txt?

AI crawlers that respect robots.txt read this file, so the Sitemap line is visible to them. However, OpenAI, Anthropic and Perplexity do not document how they use it to discover pages. Declaring your sitemap remains useful for Google and Bing, whose indexes feed AI Overviews and Copilot, but it does not guarantee any citation in a generated answer.

Updated on

Topic checklist (PDF)

And now?

In the “Crawling” topic

  1. Check robots.txt access and syntax
  2. Allow Googlebot on strategic pages
  3. Allow Bingbot on strategic pages
  4. Allow required CSS/JS resources
  5. Declare sitemaps in robots.txt
  6. Generate the XML sitemap automatically
  7. Include only indexable canonical URLs returning HTTP 200
  8. Exclude redirects, errors and noindex pages
  9. Provide a reliable lastmod
  10. Split large sitemaps
  11. Stay within 50,000 URLs and 50 MB uncompressed per sitemap
  12. Submit sitemaps to Google and Bing
  13. Analyze crawl stats
  14. Analyze server logs
  15. Identify crawler traps
  16. Optimize crawl budget if warranted
  17. Check CDN, WAF and anti-bot protection
  18. Check that public pages are accessible without authentication
  19. Monitor DNS and server errors
  20. Set up IndexNow if relevant