How to Add Your Sitemap to robots.txt (and How the Two Files Differ)

Learn how to effectively add your sitemap xml robots txt and understand the differences between these two essential files in our step-by-step guide.

How to Add Your Sitemap to robots.txt (and How the Two Files Differ)

sitemap xml robots txt | Updated October 2026 | hyperank Editorial Team | 10-20 minutes | Beginner

What You'll Learn

To add your sitemap to robots.txt, put one line anywhere in the file: Sitemap: https://www.example.com/sitemap.xml, using the full, absolute URL. You can add several Sitemap lines, or point to a single sitemap index file that lists the rest. The two files do different jobs: robots.txt tells crawlers which URLs they may crawl, while sitemap.xml lists the URLs you want them to find. Referencing the sitemap in robots.txt helps every crawler discover it; for Google, also submit it in Search Console and validate both files. This guide, How to Add Your Sitemap to robots.txt (and How the Two Files Differ), shows the exact syntax, how sitemap xml robots txt settings work together, how to fix a "sitemap.xml not indicated in robots.txt" warning and how to check everything works.

  • The one-line fix: Exact syntax for the Sitemap directive.
  • The difference: What robots.txt and sitemap.xml each control.
  • Multiple sitemaps: How to list several, or use a sitemap index.
  • Verification: Submitting in Search Console and validating both files.

Prerequisites: Access to edit robots.txt (through your server, CMS or SEO plugin) and a working sitemap URL.


Why Adding Your Sitemap to robots.txt Matters in 2026

robots.txt is the first file most crawlers request when they visit a site, so it's the natural place to tell them where your sitemap lives. Google's robots.txt specification says that "Google, Bing, and other major search engines support the sitemap field in robots.txt," and that the field "isn't tied to any specific user agent and may be followed by all crawlers."

That matters more now that many bots visit your site, not just Googlebot and Bingbot. AI search engines run their own crawlers too, and a sitemap reference in robots.txt is a standard, zero-cost way to help any compliant crawler find your important pages.

It also matters because Google retired its sitemap ping endpoint in 2023, leaving robots.txt and Search Console as the main ways to point Google at your sitemap.


The Process at a Glance

StepActionTimeOutcome
1Add the Sitemap line to robots.txt2 minCrawlers can find sitemap
2Understand what each file is3 minClear roles for both files
3Know what each file controls3 minNo conflicting instructions
4Add several sitemaps or an index5 minAll sitemaps referenced
5Fix the "not indicated" warning5 minAudit warning cleared
6Submit the sitemap in Search Console3 minGoogle reports on sitemap
7Validate both files5 minBoth files error-free

Total time: About 10 to 20 minutes.


Step 1: Add the One Line You Need

What You're Doing

This is the whole fix for most sites: one line in robots.txt that points to your sitemap.

Hyperank Media panel showing Sitemap URL field filled with a sitemap.xml address

How to Do It

  1. Open your robots.txt file. It lives at the root of your site, for example https://www.example.com/robots.txt.
  2. Use the complete, absolute URL, including https:// and the exact host (www or non-www) your site uses.
  3. Save and upload the file, then load it in a browser to confirm the line is there.

Put it anywhere in the file. A common convention is the end:

User-agent: *
Disallow: /cart/
Disallow: /checkout/

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

Add this line, replacing the URL with your sitemap's full address:

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

Our free sitemap to robots.txt generator creates the Sitemap lines for you, with optional Allow, Disallow and Crawl-delay rules.

Common Mistakes

  • Relative paths: Sitemap: /sitemap.xml isn't valid; the spec requires an absolute URL.
  • Wrong case in the URL: Google's spec says the field name is case-insensitive but the value is case-sensitive, so /Sitemap.xml and /sitemap.xml are different URLs.

What Done Looks Like

Your live robots.txt shows a Sitemap line with the full URL of a sitemap that loads.


Step 2: Know What robots.txt and sitemap.xml Are (Side by Side)

What You're Doing

With the line in place, it's worth understanding what you just connected. The two files are often mentioned together, so you're getting clear on what each one actually is.

How to Do It

robots.txtsitemap.xml
What it isA plain text file of crawl rulesAn XML file listing URLs
Where it livesMust be at the root: /robots.txtUsually at the root; can be elsewhere
Who reads itCrawlers, before crawlingCrawlers looking for pages to discover
Main jobAllow or disallow crawling of pathsList pages you want found
Format rulesUTF-8 text; Google enforces a 500 KiB limitUTF-8 XML; up to 50,000 URLs or 50MB uncompressed
Required?No, but recommendedNo, but recommended
  • robots.txt: Google's spec says you must place it in the top-level directory of a site and that it must be a UTF-8 encoded plain text file.
  • sitemap.xml: Defined by the sitemaps.org protocol; Google's sitemap guide covers the size limits and format. Our guide to creating an XML sitemap walks through building one.

What Done Looks Like

You can describe each file's purpose in one sentence.


Step 3: Understand sitemap.xml vs robots.txt: What Each Controls

What You're Doing

Knowing what each file is leads straight to what each one does. The most common mistake is expecting one file to do the other's job, so you're learning exactly what each controls.

How to Do It

  • robots.txt controls crawling, not indexing: A disallowed URL can still be indexed without its content if other pages link to it. To keep a page out of results, use a noindex tag and don't block it in robots.txt, or Google can't see the tag.
  • sitemap.xml suggests, it doesn't force: Listing a URL helps discovery, but doesn't guarantee crawling or indexing.
  • The Sitemap line is the only overlap: robots.txt can tell crawlers where the sitemap is. Google's spec notes that crawlers may follow it "provided it isn't disallowed for crawling."
  • Don't contradict yourself: If a URL is in your sitemap, it shouldn't be blocked in robots.txt.

Example

GoalRight toolWrong tool
Help crawlers find new blog postssitemap.xml, referenced in robots.txtrobots.txt Allow lines
Stop crawling of cart and checkout pagesrobots.txt DisallowLeaving them out of the sitemap only
Keep a thank-you page out of Googlenoindex tagrobots.txt Disallow
Show Google the main version of duplicatesCanonical tags, canonical URLs in sitemaprobots.txt

Check how your current rules treat any URL with our robots.txt checker, which tests URLs against the file using Google's longest-match logic.

What Done Looks Like

Nothing in your sitemap is blocked by robots.txt, and you use noindex, not robots.txt, to keep pages out of results.


Step 4: Add One or Several Sitemaps (Sitemap Index Files)

What You're Doing

One sitemap is simple; many sites have more. You're making sure all of them are discoverable.

How to Do It

  1. Build an index with our free sitemap index generator, which turns a list of sitemap URLs into a valid sitemap_index.xml.
  2. Sitemaps on another host: Google's sitemap guide shows that robots.txt on example.com can reference a sitemap hosted elsewhere, such as a CDN, as long as you control both sites.

Option B, use a sitemap index: Create one index file that lists all your sitemaps, and reference only the index. Sitemaps.org says you "can include the location of just that file" and don't need to list each sitemap in it. An index can list up to 50,000 sitemaps.

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

Option A, list each sitemap: Google's spec says you can specify multiple sitemap fields, with no limit:

Sitemap: https://www.example.com/sitemap-posts.xml
Sitemap: https://www.example.com/sitemap-products.xml
Sitemap: https://www.example.com/sitemap-pages.xml

Best Practices

  • Prefer an index on big sites: One line is easier to maintain than dozens.
  • Match your CMS: WordPress SEO plugins often create /sitemap_index.xml; reference that, not each child sitemap.

What Done Looks Like

Every sitemap you publish is either listed in robots.txt or included in an index file that is.


Step 5: Fix "sitemap.xml Not Indicated in robots.txt"

What You're Doing

Some SEO audit tools flag this warning when robots.txt has no Sitemap line. You're clearing it properly.

How to Do It

  1. Confirm the warning is real: open yourdomain.com/robots.txt and look for a line starting with "Sitemap:".
  2. Find your sitemap's actual URL with our sitemap finder, which checks robots.txt, common paths and homepage links.
  3. Add the Sitemap line from Step 1 with that exact URL.
  4. If you use WordPress, check whether your SEO plugin manages a virtual robots.txt; edit it in the plugin rather than uploading a file that may be ignored. Our guide to the WordPress robots.txt file explains how.
  5. Clear any caching or CDN layer so the updated file is served. More than one "it still says missing" ticket has turned out to be a cached file.
  6. Re-run the audit tool.

Common Mistakes

  • Pointing to a sitemap that redirects or 404s: The warning may clear, but crawlers still can't use it.
  • Using the wrong host: A sitemap on http:// or a different subdomain than your live site confuses tools and crawlers.

What Done Looks Like

The audit tool no longer shows the warning, and the referenced sitemap loads with a 200 status.


Step 6: Submit the Sitemap in Search Console as Well

What You're Doing

The robots.txt line is for every crawler; Google deserves a direct note too. Search Console tells Google exactly where the sitemap is and gives you a report on it.

Google Search Console about page with the Start now button highlighted

How to Do It

  1. Open Google Search Console and choose your property.
  2. Go to Indexing > Sitemaps.
  3. Enter the sitemap or sitemap index URL under "Add a new sitemap" and click Submit.
  4. Check the status: "Success" means Google read it.
  5. Do the same in Bing Webmaster Tools under Sitemaps.

Google's sitemap guide lists both methods: submitting through the Sitemaps report and adding the Sitemap line to robots.txt. Using both gives you discovery by all crawlers plus Google's processing report.

What Done Looks Like

Search Console shows your sitemap with a "Success" status and a count of discovered URLs.


Step 7: Validate Both Files

What You're Doing

The last step is making sure neither file has errors that undo your work.

How to Do It

  1. Validate the sitemap: Run it through our XML sitemap validator, which checks format, off-domain entries and missing tags.
  2. Test robots.txt: Use the robots.txt checker to confirm key pages and the sitemap URL itself aren't blocked.
  3. Check Search Console's robots.txt report: It shows the robots.txt files Google found and any fetch problems.
  4. Spot-check sitemap URLs: A few listed pages should return 200, be indexable and not be disallowed.
  5. Re-check after changes: Migrations, CMS updates and new plugins often rewrite one file or the other.

Both files also matter for AI crawlers, which read robots.txt like any other bot. To see whether AI engines actually mention your brand once they can reach you, hyperank asks six major AI engines your buyers' questions every day and shows what they say, what they get wrong and which competitors they recommend.

What Done Looks Like

Both files validate, key pages are crawlable, and the sitemap is referenced and submitted.


What to Do After Adding Your Sitemap

  • Phase 1, first week, confirm: Check Search Console's Sitemaps and robots.txt reports for errors.
  • Phase 2, first month, compare: Review how many sitemap URLs are indexed and investigate gaps.
  • Phase 3, ongoing, maintain: Re-validate both files after every migration or major site change; our technical SEO audit checklist includes both.

Resources You'll Need

ResourceRoleLabelPrice
hyperank sitemap to robots.txt generatorCreates Sitemap lines and basic rulesRecommendedFree
hyperank robots.txt checkerTests URLs against your rulesRecommendedFree
hyperank XML sitemap validatorChecks sitemap format and entriesRecommendedFree
Google Search ConsoleSitemaps and robots.txt reportsRequiredFree
Google's robots.txt specificationOfficial syntax rulesOptionalFree

Troubleshooting Common Issues

The Sitemap line is there but tools say it's missing

Likely cause: A cached robots.txt, or a CMS serving a different virtual file. Fix: Clear caches, check the file in a private browser window, and edit it where your CMS manages it.

Search Console says the sitemap "Couldn't fetch"

Likely cause: The URL is wrong, blocked by robots.txt or a firewall, or redirects. Fix: Open the exact URL, make sure robots.txt doesn't disallow it, and resubmit.

Pages in the sitemap show as "Blocked by robots.txt"

Likely cause: A Disallow rule covers URLs you also list in the sitemap. Fix: Remove the conflicting Disallow or take those URLs out of the sitemap.

Changes to robots.txt aren't taking effect

Likely cause: Google caches robots.txt for a while. Fix: Wait, or request a recrawl through Search Console's robots.txt report.


Conclusion

Getting sitemap xml robots txt settings right takes one line: Sitemap: followed by the full URL of your sitemap or sitemap index, placed anywhere in robots.txt. Remember that robots.txt controls crawling while the sitemap lists pages to discover, submit the sitemap in Search Console too, and validate both files.

Key Takeaways

  • Outcome: Your sitemap is referenced in robots.txt, submitted to Google and validated.
  • Key insight: robots.txt and sitemap.xml do different jobs and must never contradict each other.
  • Next action: Open your robots.txt now and check for a Sitemap line with an absolute URL.

FAQ

How do you add your sitemap to robots.txt, and how do the two files differ?

How to Add Your Sitemap to robots.txt (and How the Two Files Differ): add one line anywhere in robots.txt, Sitemap: https://www.example.com/sitemap.xml, using the sitemap's full absolute URL. You can add several Sitemap lines or reference one sitemap index file. The files differ in purpose: robots.txt is a plain text file at your site root that tells crawlers which paths they may crawl, while sitemap.xml is an XML list of URLs you want crawlers to find. robots.txt controls crawling, not indexing, and URLs in your sitemap shouldn't be blocked by robots.txt.

What is robots.txt and sitemap.xml?

robots.txt is a text file of crawl rules at the root of a site. sitemap.xml is an XML file listing the URLs you want search engines to discover.

Where should the Sitemap line go in robots.txt?

Anywhere. The directive is independent of user-agent groups, so its position doesn't matter; many sites put it at the end.

Can I list more than one sitemap in robots.txt?

Yes. Google says there's no limit to the number of Sitemap lines. Alternatively, reference a single sitemap index.

Do I still need to submit my sitemap in Search Console?

It's recommended. robots.txt helps all crawlers discover it; Search Console confirms Google read it and reports errors.

What does "sitemap.xml not indicated in robots.txt" mean?

An audit tool found no Sitemap line in your robots.txt. Add one with your sitemap's full URL to clear it.

Does robots.txt stop pages from being indexed?

No. It controls crawling. A blocked URL can still be indexed without its content; use noindex to keep a page out of results.


Methodology: Syntax and rules come from Google's robots.txt specification and sitemap documentation and the sitemaps.org protocol. The "not indicated" warning wording varies by audit tool; we haven't attributed it to a specific product.

See where your brand stands

How six AI engines describe you, next to your competitors. About two minutes.

Check your brand free