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.

Contents
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.xmlis not valid here. - It can go anywhere in the file. It doesn’t belong to any
User-agentgroup, 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
- Find your sitemap address. Not sure what it is? Enter your domain in our sitemap finder.
- 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 namedrobots.txt, or make a complete one with our Robots.txt Generator. - Add the
Sitemap:line with the full address, on its own line. - Save and check by opening
https://yourdomain.com/robots.txtin your browser.
Platform-specific notes
| Platform | How to edit robots.txt |
|---|---|
| WordPress | WordPress 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. |
| Shopify | Shopify’s robots.txt already includes /sitemap.xml. You can customise it with a robots.txt.liquid theme template. |
| Wix / Squarespace | The sitemap is added automatically. Wix lets you edit robots.txt in its SEO settings. |
| Custom sites | Edit 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
httpsaddress with the samewwwsetting 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.


