Sub topic 8
What an XML Sitemap Does and Does Not Do
This chapter covers what a sitemap can change about how a search engine treats your site, and what it can't. It assumes you know what URLs and HTTP status codes are, can read basic XML, and have met robots.txt in the earlier chapters. The next chapter covers the file's syntax. This one covers the purpose and the limits, which decide what you put in the file.
What a sitemap is
An XML sitemap is a file that lists URLs on your site that you want search engines to know about. Crawlers fetch it like any other file and read the <loc> entries. You can also attach a <lastmod> date to each URL.
A sitemap is a suggestion list. It is not a command and not a configuration file. A crawler reads it, adds the URLs to its queue of candidates, and then applies its own judgment about whether, when, and how often to fetch each one.
What a sitemap does
It helps crawlers discover URLs
Crawlers normally find pages by following links. A sitemap gives them a second route. It matters most in these cases:
| Situation | Why a sitemap helps |
|---|---|
| New site with few inbound links | Crawlers have few links to follow, so the sitemap supplies the URL list. |
| Large site with deep structure | Pages many clicks from the home page may be reached late or rarely. |
| Orphan pages (no internal links) | The sitemap may be the only place the URL appears. |
| Frequently added content, such as news or listings | New URLs show up in one place with a date. |
| Pages whose links are hard to follow, such as links created only by JavaScript | The sitemap lists the URL as plain text. |
Small sites with solid internal linking often do fine without a sitemap. Adding one rarely hurts, but it is not what makes such a site visible.
It signals which URLs you consider important
Listing a URL says "this is a page I want in search results". Leaving a URL out says nothing negative, but a clean sitemap that contains only your preferred URLs is a useful signal. Search engines compare it with other signals such as canonical tags and internal links.
It can carry freshness hints
With an accurate <lastmod>, a crawler can decide to re-fetch pages that changed and skip pages that did not. This only works if the dates are honest. The next chapter covers that.
It gives you reporting
Google Search Console reports, per submitted sitemap, how many URLs were found and what happened to them. The Page indexing report can be filtered to the URLs in one sitemap. If you split sitemaps by section (blog, products, help pages), you can see which section has indexing problems. This is often the most practical benefit on a large site.
What a sitemap does not do
It does not guarantee crawling or indexing
Crawling is fetching a URL. Indexing is storing and analyzing the page so it can appear in results. A listed URL can be skipped for many reasons: low perceived quality, duplicate content, server errors, a noindex directive, a canonical tag pointing elsewhere, or limited crawl capacity. "Discovered, currently not indexed" is a common status for URLs that were found through a sitemap but not yet crawled or kept.
It does not influence ranking directly
Being in a sitemap does not raise a page's position. Ranking is a separate step that happens after indexing.
It does not override other directives
When signals conflict, the sitemap loses. Examples:
- A URL that is blocked in robots.txt stays blocked, even if the sitemap lists it. The crawler can't fetch it.
- A page with
noindexstays out of the index, even if the sitemap lists it. - A page with a canonical tag pointing to another URL is usually treated as a duplicate, even if the sitemap lists it.
A sitemap that contradicts your own directives sends mixed signals and makes your reports noisy. Treat each such conflict as a bug in your site.
It does not replace internal linking
Search engines use links to understand how pages relate and which ones matter. A page that is only in the sitemap, with no links pointing to it, is discovered but weakly connected to the rest of the site. Keep a sitemap and good navigation.
It does not remove or block anything
Removing a URL from the sitemap does not remove it from the index. To keep a page out of the index, use noindex (see the chapter on Disallow versus noindex). To remove one that is already indexed, return 404 or 410, or use the search engine's removal tools.
Priority and change frequency are not controls
The format allows <priority> and <changefreq> elements. Google has said it ignores both. Don't spend time tuning them.
What belongs in a sitemap
A good rule is to list only URLs you would be happy to see in search results. In practice that means each URL should:
- Return HTTP 200.
- Be the canonical version (not a duplicate with a different canonical).
- Be allowed by robots.txt.
- Be indexable (no
noindex). - Use the exact preferred form: scheme, host, and trailing-slash style as in your canonical tags.
| URL type | Include? | Reason |
|---|---|---|
| Canonical article or product page returning 200 | Yes | This is what the file is for. |
| URL that redirects (301/302) | No | List the destination instead. |
| URL returning 404 or 410 | No | It wastes crawl effort and clutters reports. |
| Page with `noindex` | No | It contradicts your own directive. |
| Parameter variants, such as `?sort=price` | No | They duplicate the canonical page. |
| Page blocked by robots.txt | No | The crawler can't fetch it. |
| Internal search results, login, cart | No | They offer no value in results. |
The chart below shows how a sitemap fits next to other discovery routes. The filters on the right apply no matter how the URL was found.
Auditing a sitemap for conflicts
You can check the rules above with a short script. This one reads a sitemap, checks each URL against the site's robots.txt, and reports URLs that don't return 200. It does not follow redirects, so a 301 is reported instead of hidden. It handles a plain urlset file, not a sitemap index.
import urllib.error
import urllib.parse
import urllib.request
import xml.etree.ElementTree as ET
from urllib.robotparser import RobotFileParser
NS = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"}
HEADERS = {"User-Agent": "sitemap-audit/1.0"}
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, *args, **kwargs):
return None
opener = urllib.request.build_opener(NoRedirect)
def status(url):
req = urllib.request.Request(url, method="HEAD", headers=HEADERS)
try:
with opener.open(req, timeout=10) as resp:
return resp.status
except urllib.error.HTTPError as err:
return err.code
def audit(sitemap_url):
req = urllib.request.Request(sitemap_url, headers=HEADERS)
with urllib.request.urlopen(req, timeout=10) as resp:
root = ET.parse(resp).getroot()
parts = urllib.parse.urlsplit(sitemap_url)
rp = RobotFileParser(f"{parts.scheme}://{parts.netloc}/robots.txt")
rp.read()
for loc in root.findall("sm:url/sm:loc", NS):
url = loc.text.strip()
problems = []
if not rp.can_fetch("*", url):
problems.append("blocked by robots.txt")
code = status(url)
if code != 200:
problems.append(f"status {code}")
if problems:
print(url, "->", "; ".join(problems))
if __name__ == "__main__":
audit("https://www.example.com/sitemap.xml")Replace the example URL with your own. Any line the script prints is a URL that should be fixed or removed from the sitemap. The script does not check noindex or canonical tags, which need the page's HTML or headers.
Common mistakes
- Listing everything the CMS can generate. Tag archives, paginated duplicates, and parameter URLs dilute the file. Generate the list from pages you actually want indexed.
- Treating "submitted" as "indexed". A sitemap with 10,000 URLs and 6,000 indexed is not a failure by itself. Look at the reasons for the rest.
- Using the sitemap to hide pages. Sitemaps are public. Anyone can read yours, including at the location listed in robots.txt.
- Mixing hosts or schemes. A sitemap at
https://www.example.com/should list URLs on that host with that scheme. Listinghttp://or non-wwwvariants creates duplicates and may be ignored. - Leaving stale URLs after a migration. Old URLs that now redirect should be replaced with the new ones.
Exercise
A page returns 200 and is listed in your sitemap, but it contains a noindex meta tag. What will most likely happen, and what should you change?
Show answer
The search engine can crawl the page, but it will honor noindex and keep the page out of the index. The sitemap does not override it. Remove the URL from the sitemap, or remove the noindex tag if you actually want the page indexed. Which one depends on your goal.
Exercise
Your sitemap lists 500 product URLs. Search Console shows 380 indexed. Name two actions that would help you find out why the other 120 were not indexed.
Show answer
Any two of these: filter the Page indexing report to that sitemap and read the reason given for each excluded URL; run an audit like the script above to find redirects, 404s, or robots.txt blocks; check for noindex tags and canonical tags that point elsewhere; split the products into several sitemaps by category to see which group has the problem.
Exercise
True or false: setting priority to 1.0 on a URL makes search engines crawl it first. Explain.
Show answer
False. Google has said it ignores priority (and changefreq). Use accurate lastmod values and good internal links to influence how crawlers treat your pages.