Two small files have a big say in how search engines crawl your website: robots.txt and your XML sitemap. One tells crawlers where they may and may not go. The other gives them a clean list of the pages you want found. Get them wrong and you can accidentally hide your whole site from Google. Get them right and crawlers spend their time on the pages that matter.
They’ve also become more important in 2026, because robots.txt is now where many site owners express their choices about AI crawlers and AI training. This guide covers both files in plain English.
Part 1: Robots.txt
What is robots.txt?
Robots.txt is a plain text file at the root of your domain, for example yourdomain.pk/robots.txt. Well-behaved crawlers read it before crawling your site and follow its rules about which paths they may access.
The basic rules
| Directive | What it does | Example |
|---|---|---|
| User-agent | Names which crawler the rules apply to (* means all) | User-agent: * |
| Disallow | Blocks crawling of a path | Disallow: /wp-admin/ |
| Allow | Permits a path inside a blocked folder | Allow: /wp-admin/admin-ajax.php |
| Sitemap | Points crawlers to your XML sitemap | Sitemap: https://yourdomain.pk/sitemap.xml |
A safe starting point for most WordPress sites
User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://yourdomain.pk/sitemap_index.xml
That’s enough for most small business websites. Online stores may also block internal search results and endlessly combinable filter URLs that create thousands of near-duplicate pages.
The most important thing to understand
Robots.txt controls crawling, not indexing. If you block a page in robots.txt, Google can’t read it, but it may still show the URL in results if other pages link to it. To keep a page out of search results, allow crawling and add a noindex meta tag instead. Blocking and noindexing the same page doesn’t work, because Google can’t see the noindex tag on a page it isn’t allowed to crawl.
Robots.txt and AI crawlers
Robots.txt is also how you manage AI-related crawlers. Google-Extended, for example, lets you control whether your content is used for Google’s AI models without affecting Google Search. Google and Microsoft have also announced support for new shared AI-training preferences coming in 2027, and Bing is introducing separate controls for AI training and AI grounding. We covered the details in our November 2026 Google and Bing news roundup.
Before blocking any AI crawler, decide what you want. Blocking AI answer and grounding crawlers can reduce how often your brand is cited in AI answers, which matters for AI search visibility.
Robots.txt mistakes that cause real damage
- Disallow: / left over from a staging site, which blocks the entire website.
- Blocking CSS and JavaScript files, so Google can’t render pages properly.
- Blocking pages you want removed instead of using noindex.
- Typos in paths, since rules are case-sensitive.
- Using robots.txt to hide private content. The file is public, and it doesn’t protect anything.
Part 2: XML Sitemaps
What is an XML sitemap?
An XML sitemap is a file that lists the URLs you want search engines to find, often with the date each page was last modified. It doesn’t guarantee indexing, but it helps search engines discover pages faster, especially new pages and pages with few internal links.
What belongs in your sitemap
| Include | Leave out |
|---|---|
| Service, product and category pages | Pages with a noindex tag |
| Blog posts and guides | Redirected URLs |
| City and location pages | 404 and error pages |
| Important images and videos (optional) | Thank-you pages, cart, checkout, login |
| Only the canonical version of each page | Filter, sort and tracking parameter URLs |
A clean sitemap sends a clear signal: “these are the pages that matter.” A sitemap stuffed with redirects, duplicates and noindexed pages sends a confusing one.
How to create one
Most platforms do it for you. WordPress has a basic built-in sitemap, and SEO plugins such as Yoast SEO or Rank Math generate fuller ones. Shopify creates /sitemap.xml automatically. Custom-built sites need a developer to generate it, ideally updating automatically when pages change.
Submit it to Google and Bing
- In Google Search Console, go to Indexing → Sitemaps, enter your sitemap URL and submit.
- In Bing Webmaster Tools, add the same sitemap under Sitemaps. Bing’s index also feeds Copilot and other AI and search experiences.
- Add the sitemap URL to your robots.txt file so every crawler can find it.
- Consider IndexNow, supported by Bing and others, to notify search engines instantly when pages change. Many WordPress SEO plugins include it.
Keep the lastmod date honest
The lastmod date should change only when the page content meaningfully changes. Updating every page’s date daily to look “fresh” teaches search engines to ignore the signal.
How to Check Both Files
- Visit yourdomain.pk/robots.txt in a browser and read every line.
- Check the robots.txt report in Search Console for fetch errors.
- Open your sitemap URL and confirm it loads without errors.
- In Search Console’s Sitemaps report, compare discovered URLs with the pages you expect.
- Use the URL Inspection tool on a few key pages to confirm they’re crawlable and indexable.
These checks are part of our technical SEO audit checklist, and worth repeating after every redesign or migration.
Final Thoughts
Robots.txt and XML sitemaps aren’t glamorous, but they’re foundations. Keep robots.txt short and intentional, keep your sitemap clean, submit it to both Google and Bing, and review both whenever your site changes. Five minutes of checking can prevent months of lost traffic.
Looking to Accelerate Your Performance?
Our team builds strategic search roadmaps, media outreach pipelines, and bespoke software solutions tailored to your operational goals.