Two tiny files decide a surprising amount of your search visibility, and most business owners have never opened either one. One is a polite list of the pages you want found. The other is a polite request about where crawlers shouldn't go. Get them wrong and the symptoms look like mysteries: pages that never appear, pages that appear but shouldn't, and a Search Console error nobody can explain.
The short answer
A sitemap is an XML file that lists the pages you want search engines to find and index. A robots.txt file is a plain text file at the root of your site that tells crawlers which paths they may or may not fetch. The sitemap helps discovery. Robots.txt controls crawling. Neither one guarantees indexing, and neither one is a security tool. Most problems come from the two contradicting each other, or from one of them still carrying settings from the staging site.
Want someone to check yours? Send us your link and we will tell you what to fix first. Message us on WhatsApp
What is a sitemap, and what doesn't it do?
A sitemap is a list of URLs in a format machines read easily. Each entry has an address and usually a last-modified date. Search engines use it as a to-do list: "here are the pages the owner says matter."
It helps most in three situations: a new site with few links pointing to it, a large site where some pages sit deep in the structure, and a site that publishes new pages often.
What it doesn't do is force anything. Google decides which listed pages to index based on quality and relevance, and it may leave some out. A sitemap also doesn't improve rankings by itself. Think of it as an introduction, not an endorsement.
What is robots.txt, and why isn't it a lock?
Robots.txt lives at one fixed address, yourdomain.com/robots.txt, and every host has its own, so a subdomain needs a separate file. It's made of simple groups. You name a crawler with a User-agent line (an asterisk means all of them), then list Disallow lines for paths that crawler shouldn't fetch, and Allow lines for exceptions.
The word that matters is "shouldn't". Well-behaved crawlers such as Googlebot follow it, but it's a convention, not a lock. Anyone can still open a disallowed URL in a browser, and a badly behaved bot can ignore the file entirely. So never use robots.txt to hide sensitive pages. Worse, listing a private path there tells curious people exactly where it is. Real protection means a login, permissions or removing the page.
The other classic confusion is between crawling and indexing. A blocked URL can still appear in search results as a bare link if other sites point at it, because Google knows the address exists even though it never fetched the content. To keep a page out of results, leave it crawlable and add a noindex instruction.
Sitemap and robots.txt side by side
| Question | Sitemap | robots.txt |
|---|---|---|
| Format | An XML file listing URLs | A plain text file at the root of the site |
| Job | Helps discovery: the pages you want found | Controls crawling: which paths crawlers may fetch |
| Guarantees indexing | No | No |
| A security tool | No | No, only a polite request |
How do the two files work together?
Robots.txt says where crawlers may go, and the sitemap says where you'd like them to start. For a typical business site, the whole robots.txt can be a few lines: allow everything, disallow the admin area and any internal search result pages, and finish with a Sitemap line giving the full https address of your sitemap. That last line lets any crawler find the sitemap without you submitting it anywhere.
The two must agree. If the sitemap lists a page that robots.txt blocks, you've sent a contradictory message, and Search Console will flag it.
What belongs in a sitemap, and what doesn't?
Include only the pages you actually want to appear in search, in their final form.
- Include real, indexable pages that return a 200 status.
- Include each page once, using the canonical address with the same protocol and host as the live site.
- Leave out redirected URLs, 404 pages and pages marked noindex.
- Leave out duplicates, internal search results, filter and sort variations, login and admin pages, and thank-you pages.
- Use full absolute URLs, never relative paths.
- Keep each file under 50,000 URLs and 50 MB uncompressed. Larger sites use a sitemap index that points to several files.
Be honest with the last-modified date too. It should reflect the last meaningful change to the page's content. If every page shows today's date because the sitemap regenerates on every request, Google learns to ignore the field entirely, and you lose a useful signal.
What goes in the sitemap and what stays out
| Include | Leave out |
|---|---|
| Real, indexable pages that return a 200 status | Redirected URLs, 404 pages and noindex pages |
| Each page once, at its canonical address | Duplicates, internal search results, filter and sort variations |
| Full absolute URLs | Login, admin and thank-you pages |
What if the site has two languages?
A bilingual site can put the language annotations right in the sitemap. Each page gets an entry for its own URL, and inside it, alternate links pointing at the other language versions, including itself. The pairs must be reciprocal, so the Arabic entry lists the English one and the English entry lists the Arabic one. Our guide to building an Arabic and English website that ranks in both covers hreflang in more detail.
A useful rule is that a language version only appears in the sitemap once it genuinely exists and is complete. A half-translated page listed as a language twin sends the wrong signal.
How do you submit a sitemap, and what if Search Console can't read it?
In Google Search Console, open the Sitemaps section, enter the sitemap's address and submit it. Check back in a day or two. A status of Success means Google fetched and parsed it. You can then watch how many of the listed pages are discovered and indexed.
If you see "Couldn't fetch" or "Can't be read", don't panic and don't resubmit ten times. Work through the likely causes in order:
- The address is wrong or redirects. Open the sitemap URL in a private browser window. It should load directly with a 200 status. A chain of redirects, such as http to https to www, can make the fetch fail.
- The response isn't clean XML. The file must be valid and start straight with the XML declaration. A blank line, a space or an invisible byte-order mark before it can break parsing. An HTML error page returned with a 200 status is another classic.
- The content type is off. It should be XML. If the server labels it as an HTML page, some readers refuse it.
- A firewall is blocking Googlebot. Some hosts and security plugins challenge or block unfamiliar bots. Check your server logs for Googlebot requests to the sitemap and what status they received.
- Robots.txt blocks the sitemap path. Surprisingly common.
- The server is slow or erroring. A timeout or a 500 error at the wrong moment produces the same message.
The first fetch also sometimes fails for no lasting reason. If everything above checks out, wait a day and look again before changing anything.
Not sure what your robots.txt is blocking? Send it to us. Send it on WhatsApp
When Search Console cannot read your sitemap
| Likely cause | What to check |
|---|---|
| The address is wrong or redirects | Open it in a private window: it should load directly with a 200 status |
| The response is not clean XML | It must start straight with the XML declaration, with no blank line or byte-order mark, and an HTML error page must not be returned with a 200 status |
| The content type is off | It should be XML |
| A firewall is blocking Googlebot | Check your server logs for Googlebot requests to the sitemap and the status they received |
| Robots.txt blocks the sitemap path | Check the file |
| The server is slow or erroring | Look for timeouts or 500 errors |
Should a sitemap be a static file or generated?
A static file is simple and fast, and it goes stale the moment you add a page. A generated sitemap, built by your CMS or framework from the database, stays current automatically, which is why we prefer it. The price is a few extra things to watch.
Generated sitemaps are usually cached, since building one on every request would be wasteful, so confirm that publishing or editing a page clears that cache. Confirm that unpublished and scheduled content stays out until its date. And confirm that if an old static sitemap.xml file is still sitting on the server, it isn't silently overriding the generated one. After any launch or migration, open the live sitemap yourself and read it. It takes two minutes and catches most surprises. This check is part of our pre-launch SEO checklist, and it's worth repeating on the monthly maintenance round.
A system's private pages should never be in a sitemap
If your business has a login area, an admin panel or customer records, those pages must stay out of search engines completely, and robots.txt alone is not protection, it is only a polite request. Real protection comes from the system itself: pages that need a login, permissions that match each role, and no private page listed anywhere public. We set this up as part of the build so you do not discover it in a search result later.
Has a private area on your site or system? Ask us to check that it is truly closed. Talk to us on WhatsApp
Frequently asked questions
Does robots.txt keep my admin pages safe?
No. It only asks well-behaved crawlers to stay away. Safety comes from requiring a login and checking permissions. Ask us to check yours on WhatsApp.
Does a small website need a sitemap?
Not strictly. If every page is linked from your navigation, search engines will find them anyway. A sitemap is still worth having because it costs almost nothing and gives you a clean report in Search Console.
Does Disallow in robots.txt remove a page from Google?
No. It only asks crawlers not to fetch the page. The URL can still be listed if others link to it. Use noindex on a crawlable page, or remove the page, to take it out of results.
How often should the sitemap update?
Whenever your pages change. A generated sitemap does that on its own. If you maintain a static file by hand, regenerate it each time you add, remove or move a page.
Check them today
Open yourdomain.com/robots.txt and yourdomain.com/sitemap.xml in a browser. If either one surprises you, that's useful information. If you'd like a second opinion on your site's setup, get in touch, or see how we approach it in our web development service.
Want us to run both checks for your site today? Send us the link. Start on WhatsApp