How to Add Sitemap to Robots.txt (2026 Guide)
Want to add sitemap to robots.txt so search engines find it? You should. In April 2007, Google, Yahoo!, Microsoft and Ask.com announced support for sitemap autodiscovery: by adding one line to your robots.txt file, every search engine can find your XML sitemap without you submitting it to each one. The same file is also where you can block AI crawlers such as GPTBot. Nearly 20 years later, this is still one of the simplest SEO tasks. Here is how to add a sitemap to robots.txt in 2026, with examples for WordPress.

Quick answer: To add a sitemap to robots.txt, add a line with the full sitemap URL anywhere in the file, for example Sitemap: https://www.example.com/sitemap_index.xml. Use an absolute URL, add one line per sitemap, and also submit the sitemap in Google Search Console and Bing Webmaster Tools.
Table of Contents
How to add a sitemap to robots.txt
- Find your sitemap URL. WordPress core creates
/wp-sitemap.xml; SEO plugins like Rank Math and Yoast use/sitemap_index.xml. - Open your robots.txt file at the root of your site (yoursite.com/robots.txt).
- Add the Sitemap line with the full URL:
User-agent: * Disallow: /wp-admin/ Allow: /wp-admin/admin-ajax.php Sitemap: https://www.example.com/sitemap_index.xml - Save the file and open yoursite.com/robots.txt in a browser to check it.
The Sitemap line is independent of User-agent groups, so it can go at the top or bottom. See also the correct way to add a sitemap link to robots.txt.
Add a sitemap to robots.txt in WordPress
- No physical robots.txt: WordPress serves a virtual robots.txt and adds the core sitemap automatically in recent versions.
- Rank Math: go to Rank Math > General Settings > Edit robots.txt. Rank Math adds the sitemap line for you when its sitemap is enabled.
- Yoast SEO: use Yoast SEO > Tools > File editor, and add the Sitemap line if it is missing.
- Physical file: if a robots.txt file exists in your site root, it overrides the virtual one, so edit it by FTP or your host’s file manager.
Rules for the sitemap line
- Use the full absolute URL, including https:// and the right www or non-www version.
- You can list several sitemaps, one per line, or point to a sitemap index file.
- A sitemap can list up to 50,000 URLs or 50 MB uncompressed; use an index for more, as defined by sitemaps.org (external site, opens in new tab).
- Do not block the sitemap URL itself with a Disallow rule.
Submit your sitemap too
Robots.txt autodiscovery helps every crawler find your sitemap, but you also get reports when you submit it directly:
- Google Search Console (external site, opens in new tab): Indexing > Sitemaps > add your sitemap URL.
- Bing Webmaster Tools (external site, opens in new tab): Sitemaps > Submit sitemap.
Google retired its old sitemap “ping” URL in 2023, so plugins no longer need to ping Google on every post. Bing and other engines support IndexNow for faster updates.
What changed since 2007?
In 2007 I used the Google Sitemaps Generator WordPress plugin, which pinged Google and Yahoo! on every new post, and Ask.com, Google, Microsoft Live Search and Yahoo! had just agreed to support autodiscovery. Today Yahoo! search uses Bing, Live Search became Bing, and Ask.com no longer runs its own crawler, but the Sitemap line in robots.txt still works the same way.
Want to keep some pages out of search instead? See ways to prevent search engines from indexing your site.
FAQ
Is it necessary to add a sitemap to robots.txt?
It is not required, but it is a free, easy way to help all search engines find your sitemap.
Where should the sitemap line go in robots.txt?
Anywhere in the file. Many sites put it at the end.
Can I add more than one sitemap?
Yes. Add one Sitemap line for each, or use a single sitemap index.
Does Google still read sitemaps in robots.txt?
Yes. Google discovers sitemaps listed in robots.txt, and you can also submit them in Search Console.
Subscribe to our weekly tech newsletter
🎁 Free 100 Tech Terms ebook when you subscribe. Unsubscribe anytime. Privacy







yes i agree with you , but some site the sitemap like index.php?action=sitemap;xml
but this may getting some problem ..
its there any solution to over this problem
Thanks for that. Having 6 accounts on six different search engine sites trying to keep my sitemap up to date and also making sure the search engines have all my site maps was starting to get a headache. Thanks
But, why have you put that under disallow section in your site?