Before Google can rank a page, it must find it, crawl it and add it to its index. Two small files guide that process: the XML sitemap, which lists the pages you want found, and robots.txt, which tells crawlers where they may and may not go. Mistakes in either can hide your whole website.
What Is an XML Sitemap?
An XML sitemap is a file listing the important URLs on your site, often with the date each was last updated. It works like a map for search engines. It does not guarantee indexing, but it speeds up discovery, especially for new or deep pages.
What to Include
- Pages you want in search results, such as services, products, categories and blog posts.
- Only canonical URLs that return a 200 status.
- Accurate last modified dates.
What to Leave Out
- Redirected, 404 and noindex pages.
- Duplicate and parameter URLs.
- Thank-you pages, internal search and admin pages.
How to Create and Submit One
- In WordPress, Yoast SEO and similar plugins generate a sitemap index automatically, usually at /sitemap_index.xml.
- Split large sites into several sitemaps by type, such as pages, posts and services.
- Keep each file under 50,000 URLs or 50 MB.
- Submit the address in Google Search Console and add it to robots.txt. See our Search Console guide.
What Is robots.txt?
Robots.txt is a plain text file at the root of your site, such as yourdomain.com/robots.txt. It gives crawl instructions to search engine bots, using rules like User-agent, Disallow and Allow.
Useful Things Robots.txt Can Do
- Block admin or internal search pages from crawling.
- Reduce wasteful crawling of filters and parameters.
- Point bots to your sitemap with a Sitemap line.
What Robots.txt Cannot Do
- It does not remove a page from Google. A blocked page can still appear if others link to it. Use a noindex tag instead, and let the page be crawled so Google can see it.
- It does not secure private content. Anyone can read the file.
A Simple Example
A typical WordPress robots.txt allows all bots, blocks the admin folder but keeps admin-ajax.php available, and lists the sitemap address. For security-minded rules, see how to harden a WordPress site.
Common Mistakes
- Blocking the whole site: a leftover “Disallow: /” from a staging site is a classic launch error.
- Blocking CSS and JavaScript: Google needs them to render the page.
- Listing noindex or redirected URLs in the sitemap.
- Forgetting to update the sitemap after a redesign. See the redesign SEO checklist.
- Having several conflicting sitemaps.
How to Test
- Open your robots.txt and sitemap in a browser.
- Use Search Console’s robots.txt report and Sitemaps report.
- Use the URL Inspection tool on key pages.
- Crawl the site and compare with the sitemap.
For wider checks, read AI SEO audit: find and fix technical issues.
Frequently Asked Questions
Do I need both a sitemap and robots.txt?
It is best practice. A sitemap helps discovery, and robots.txt manages crawling.
How often does the sitemap update?
With a plugin, it updates automatically when you publish or edit content.
Can robots.txt improve rankings?
Not directly, but it helps crawlers spend time on your important pages.