How to Add Your Sitemap to robots.txt (With Examples)

One line helps every search engine find your sitemap. Copy-paste examples for every setup.

How to Add Your Sitemap to robots.txt (With Examples)
Contents
  1. What is robots.txt?
  2. The Sitemap directive
  3. robots.txt examples
  4. How to add your sitemap to robots.txt
  5. Platform-specific notes
  6. Common mistakes to avoid
  7. Is robots.txt enough?

Adding your sitemap to robots.txt takes one line, and it lets every search engine find your sitemap automatically — even the ones you never submit it to. It also fixes the SEO audit warning “Sitemap.xml not indicated in robots.txt”. Here is exactly how to do it, with examples for single sitemaps, sitemap indexes and multiple sitemaps.

What is robots.txt?

robots.txt is a small text file in the root of your website, at https://yourdomain.com/robots.txt. Search engines read it before crawling to learn which areas they may visit. It can also point them to your sitemap with a Sitemap: line.

The Sitemap directive

The line looks like this:

Sitemap: https://example.com/sitemap.xml
  • Use the full address, including https:// and your domain. A relative path like /sitemap.xml is not valid here.
  • It can go anywhere in the file. It doesn’t belong to any User-agent group, so all crawlers see it. Most people put it at the bottom.
  • You can add more than one Sitemap: line.
  • The sitemap can even be on another domain, for example a CDN — as long as the robots.txt is on the site the sitemap covers.

robots.txt examples

A simple site with one sitemap

User-agent: *
Disallow: /admin/

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

A site with a sitemap index (Yoast, Rank Math, large sites)

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

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

List only the index — search engines read the sitemaps inside it automatically.

A site with several separate sitemaps

User-agent: *
Disallow:

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

How to add your sitemap to robots.txt

  1. Find your sitemap address. Not sure what it is? Enter your domain in our sitemap finder.
  2. Open your robots.txt file. Use your hosting file manager or FTP, and look in the root folder (usually public_html). If there is no file, create a plain-text file named robots.txt, or make a complete one with our Robots.txt Generator.
  3. Add the Sitemap: line with the full address, on its own line.
  4. Save and check by opening https://yourdomain.com/robots.txt in your browser.

Platform-specific notes

PlatformHow to edit robots.txt
WordPressWordPress shows a virtual robots.txt that already lists wp-sitemap.xml. Yoast and Rank Math add their sitemap index and have a robots.txt editor in their tools.
ShopifyShopify’s robots.txt already includes /sitemap.xml. You can customise it with a robots.txt.liquid theme template.
Wix / SquarespaceThe sitemap is added automatically. Wix lets you edit robots.txt in its SEO settings.
Custom sitesEdit the file directly in your root folder.

Common mistakes to avoid

  • Blocking the sitemap itself. A rule like Disallow: / stops crawlers from reading anything — including the sitemap.
  • Using the wrong domain version. List the https address with the same www setting as your site.
  • Listing an old sitemap that no longer exists after changing plugins.
  • Placing robots.txt in a subfolder. It only works at the root of the domain.

Is robots.txt enough?

The robots.txt line helps every search engine discover your sitemap, but you should still submit it in Google Search Console and Bing Webmaster Tools — that’s the only way to see reports on how many pages were found and whether there were errors. Our guide to submitting a sitemap to Google Search Console shows each step. If you don’t have a sitemap yet, create one with our free XML sitemap generator first.

Frequently asked questions

Quick answers to the questions we hear most. Still have a question? Ask us through our contact page.

How do I add a sitemap to robots.txt?

Add a line such as Sitemap: https://example.com/sitemap.xml to your robots.txt file, using the full address.

Where in robots.txt should the Sitemap line go?

Anywhere. It isn’t tied to a User-agent group. Most sites put it at the bottom of the file.

Can I list more than one sitemap?

Yes. Add one Sitemap: line for each sitemap or sitemap index.

Do I still need to submit my sitemap to Google?

Yes, it is recommended. Search Console shows how many pages were found and reports errors.

Crawly

Crawly is the friendly sitemap guide of XML Sitemap Generator. Every guide is written and checked by the team behind our free sitemap tools.

Related articles

Sitemap Guides

How to Submit Your Sitemap to Google Search Console

23 Nov 2026 · 6 min read
Search Console Fixes

How to Fix “Sitemap Couldn’t Fetch” in Google Search Console

23 Nov 2026 · 3 min read
Sitemap Guides

How to Create a Sitemap in WordPress (With or Without a Plugin)

23 Nov 2026 · 4 min read