Services
AI Search (AEO · GEO)
AI Search OptimizationAnswer Engine Optimization (AEO)Generative Engine Optimization (GEO)ChatGPT SEOGoogle AI Overviews & AI Mode OptimizationAI Visibility Audit
Technical SEO
Technical SEO ServicesSEO AuditCore Web Vitals & Site Speed OptimizationSEO Migration & ReplatformingSchema Markup & Structured DataInternational & Multilingual SEO
Content & On-page SEO
Keyword Research & Search Intent MappingSEO Content StrategySEO Content WritingContent Refresh & OptimisationProgrammatic SEOOn-page SEO Services
Link Building & PR
Link Building ServicesDigital PR ServicesGuest Posting ServicesBacklink Audit & DisavowBrand Mentions & Digital Citations
Specialist SEO
Local SEO ServicesEcommerce SEO ServicesEnterprise SEO ServicesSaaS SEO ServicesYouTube SEOApp Store Optimization (ASO)
Strategy & Management
SEO ConsultingMonthly SEO ManagementSEO Reporting & Analytics
AI Search (AEO · GEO)
Industries SaaS SEOB2B SEOEcommerce SEOSEO for Law FirmsHealthcare SEOReal Estate SEOFintech & Finance SEOHome Services SEODental SEOEducation & EdTech SEO
Free Tools (33)
Learn GlossaryOur method
BlogPricingAboutContactFree AI visibility audit
Blog · SEO Guides

Robots.txt and Sitemap: A Complete Guide for 2026

Learn what robots.txt and sitemaps do, how they work together, where each file lives, and how to submit both to Google and Bing, with examples.

SA
Saima AktherSEO and AEO Enthusiast
Updated 8 min read
Robots.txt and Sitemap: A Complete Guide feature image
On this pageKey takeawaysWhat does robots.txt do?What does a sitemap do?How do robots.txt and a sitemap work together?Where do robots.txt and sitemap files live?What is the correct robots.txt syntax?Step 1: Write your robots.txt fileStep 2: Create your XML sitemapStep 3: Link the sitemap in robots.txtStep 4: Submit both to Google and BingWhat are the most common robots.txt and sitemap mistakes?FAQSources
Short answerA robots.txt file tells search engines which parts of your site they may crawl, and a sitemap lists the pages you want them to find. Together they guide crawlers: robots.txt sets the limits, the sitemap hands over the map. This guide shows where each file lives, the exact syntax, and how to submit both to Google and Bing.

Key takeaways

  • Robots.txt controls crawling, not indexing. It tells crawlers which paths they may fetch; it does not remove pages from search results.
  • A sitemap lists URLs to discover. One sitemap holds up to 50,000 URLs or 50 MB uncompressed; larger sites use a sitemap index file.
  • Link the two files. Add a Sitemap: line with the full sitemap URL to robots.txt so crawlers find it on their first visit.
  • Submit both files. Submit the sitemap in Google Search Console and Bing Webmaster Tools, and test robots.txt with Google's robots.txt report.
  • The most common mistake is blocking what you want found. A stray Disallow: / or a rule that blocks CSS and JavaScript can hide whole sections of a site.

What does robots.txt do?

Robots.txt tells search engine crawlers which URLs on your site they may access, mainly to keep crawlers from overloading your site with requests. It is a plain text file that follows the Robots Exclusion Standard, standardised as RFC 9309 in September 2022. Crawlers that follow the standard read it before fetching anything else.

Robots.txt works at the level of crawling, not indexing. A page blocked by robots.txt will not be crawled, but Google may still show its URL in search results if other pages link to it. To keep a page out of search results, use a noindex rule instead.

What does a sitemap do?

A sitemap is a file that lists the pages, videos, and other files on your site that you want search engines to find. Google describes it as a way to tell search engines about pages they might otherwise miss, such as new pages, deep pages with few links, or pages on large sites.

A sitemap does not guarantee that every listed URL will be crawled or indexed. It is a hint, not an order. Google still decides what to crawl based on quality, links, and crawl budget. Even so, a correct sitemap speeds up discovery, especially for new sites and new pages.

How do robots.txt and a sitemap work together?

Robots.txt and a sitemap do opposite jobs that fit together. Robots.txt says which paths crawlers may fetch, and the sitemap says which pages are worth finding. A crawler reads robots.txt first, follows its rules, then uses the sitemap to discover URLs it has not seen yet.

The two files connect through the Sitemap: line in robots.txt. That line gives the full URL of your sitemap, so any crawler that reads robots.txt learns where the sitemap lives without waiting to find a link to it. For video content, a dedicated video sitemap works the same way and lists video pages specifically.

File Job Controls Required?
robots.txt Tells crawlers what they may fetch Crawling No, but recommended
XML sitemap Lists URLs you want discovered Discovery No, but recommended
Sitemap line in robots.txt Points crawlers to the sitemap Discovery No, but recommended

Where do robots.txt and sitemap files live?

Robots.txt lives at the root of your site, at an address such as https://www.example.com/robots.txt. A site can have only one robots.txt file per host, and it covers only that protocol, host, and port, so a subdomain needs its own file. A robots.txt file in a subfolder does not work.

A sitemap can live anywhere on your site, but its location matters. Unless you submit it through Search Console, a sitemap only affects URLs under its parent directory, so most sites put it at the root, such as https://www.example.com/sitemap.xml. A sitemap index file at the root can point to several child sitemaps.

What is the correct robots.txt syntax?

Robots.txt uses groups of rules. Each group starts with a User-agent line naming the crawler, followed by Disallow and Allow lines with paths that start with a slash. Paths are case-sensitive, and anything not disallowed may be crawled. Google also supports the * and $ wildcards in paths.

When rules conflict, Google applies the most specific rule based on path length. If two rules are equally specific and still conflict, Google uses the least restrictive one. For example, Allow: /services/ beats Disallow: / for your service pages.

Directive What it does Example
User-agent: Names the crawler a group applies to User-agent: Googlebot
Disallow: Blocks a path for that crawler Disallow: /wp-admin/
Allow: Makes an exception to a block Allow: /wp-admin/admin-ajax.php
Sitemap: Gives the full sitemap URL Sitemap: https://www.example.com/sitemap.xml
* Matches any crawler, or any characters in a path User-agent: *

Google enforces a 500 KiB size limit on robots.txt files and ignores content beyond it. Google supports User-agent, Disallow, Allow, and Sitemap, but it does not support Crawl-delay or a noindex rule inside robots.txt.

Step 1: Write your robots.txt file

Write a robots.txt file that blocks only what crawlers should skip, then test it before publishing. Start with the smallest file that does the job: allow everything, block admin and internal search pages, and add the sitemap line. A typical small business site needs very little.

User-agent: *
Disallow: /wp-admin/
Disallow: /cart/
Disallow: /search/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://www.example.com/sitemap.xml

Do not block CSS, JavaScript, or image files that crawlers need to render your pages. Google warns that blocking resources makes it harder for crawlers to understand a page, and pages that render badly may rank worse. Never list sensitive paths in robots.txt either: the file is public, and anyone can read it.

Step 2: Create your XML sitemap

Create an XML sitemap that lists the canonical URLs you want search engines to find. Most content management systems generate one automatically, and many SEO plugins do the same. A basic XML sitemap lists each URL with its location, and can also include a last-modified date.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.example.com/</loc>
    <lastmod>2026-11-28</lastmod>
  </url>
  <url>
    <loc>https://www.example.com/services/</loc>
    <lastmod>2026-11-20</lastmod>
  </url>
</urlset>

Follow three rules when building a sitemap. Use fully qualified, absolute URLs, not relative paths. Include only URLs that return a 200 status and that you want indexed, never redirects, errors, or blocked pages. Keep each sitemap under 50,000 URLs and 50 MB uncompressed, and use a sitemap index file when you need more room.

Add a Sitemap: line to robots.txt with the full, absolute URL of your sitemap. The line can go anywhere in the file, and it is not tied to any User-agent group, so all crawlers can follow it. You can list as many Sitemap: lines as you need.

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

Two details trip people up. First, the URL must be fully qualified, including the protocol and host; a relative path such as /sitemap.xml is ignored. Second, a Disallow rule that matches the sitemap's own path can still block crawlers from fetching it, so check that no rule blocks the sitemap file itself.

Step 4: Submit both to Google and Bing

Submit the sitemap to Google Search Console and Bing Webmaster Tools so both engines know about it directly. In Search Console, open the Sitemaps report and enter the sitemap URL. In Bing Webmaster Tools, open the Sitemaps section and submit the same URL. The Sitemap: line in robots.txt helps discovery, but submitting directly is faster and gives you status reports.

Then check that robots.txt works as intended. Search Console has a robots.txt report that shows the file Google fetched and flags syntax errors. After submitting, check the Sitemaps report for errors such as unreachable URLs, wrong formats, or pages Google could not fetch. Fix errors and resubmit rather than waiting for the next crawl.

  • Robots.txt is live at the site root and returns a 200 status
  • No rule blocks the sitemap, CSS, JavaScript, or important pages
  • Sitemap URL in robots.txt is a full, absolute URL
  • Sitemap submitted in Google Search Console
  • Sitemap submitted in Bing Webmaster Tools
  • Sitemaps report shows no errors after a few days

What are the most common robots.txt and sitemap mistakes?

The most common robots.txt mistake is blocking too much. A stray Disallow: / during development often goes live and hides the whole site, and blocking /wp-admin/admin-ajax.php or theme files can break rendering. The second mistake is using robots.txt to hide pages from search results: blocked pages can still appear in results, so use noindex for that job.

The most common sitemap mistakes are listing the wrong URLs and forgetting to update the file. Sitemaps that include redirects, 404 pages, or URLs blocked by robots.txt waste crawl budget and trigger errors in Search Console.

A sitemap that never updates is almost as bad, because Google learns to ignore stale files. Keep the sitemap generated automatically where possible, and check the Sitemaps report after every major site change. For a wider technical check, see our technical on-page SEO guide.

Frequently asked questions

Do I need both a robots.txt file and a sitemap?

No, neither file is required, but most sites benefit from both. Robots.txt keeps crawlers out of admin areas and internal search pages, while a sitemap helps search engines discover new and deep pages. Together they cost little to set up and remove common crawl problems.

Does robots.txt remove a page from Google?

No. Robots.txt only stops Google from crawling a page; Google may still show its URL in search results if other sites link to it. To remove a page from search results, add a noindex meta tag or header to the page itself, or remove the page and return a 404 or 410 status.

Where do I put the sitemap URL in robots.txt?

Add a Sitemap: line anywhere in robots.txt with the full, absolute URL, such as Sitemap: https://www.example.com/sitemap.xml. The line is not tied to any User-agent group. You can list several sitemap URLs if you use a sitemap index or separate sitemaps.

How do I submit a sitemap to Google?

Open Google Search Console, go to the Sitemaps report, and enter your sitemap URL. Google will fetch it and report errors. You can also help discovery by adding a Sitemap: line to robots.txt, but submitting directly gives you status reports and is the faster route.

How do I submit a sitemap to Bing?

Open Bing Webmaster Tools, go to the Sitemaps section, and submit the sitemap URL. Bing also reads the Sitemap: line in robots.txt, so one line reaches both Google and Bing. Bing's index also feeds AI search tools, so a correct sitemap helps visibility beyond Bing itself.

Can a sitemap contain more than 50,000 URLs?

A single sitemap file cannot hold more than 50,000 URLs or 50 MB uncompressed. Larger sites use a sitemap index file that lists several child sitemaps, each under the limit. Submit the index file to Google and Bing rather than each child file on its own.

Sources

SA
About the authorSaima Akther · SEO and AEO Enthusiast

Saima Akther is an SEO and AEO enthusiast who writes Serplark’s best-of lists and guides on SEO tools, answer engine optimization and AI search. Published . Spot an error or a missing tool? Tell us and we will check it.