Sitemap.xml and robots.txt Examples
A sitemap.xml lists the URLs you want crawled, each in a url element with a loc and an optional lastmod, up to 50,000 URLs or 50 MB per file. A robots.txt at the site root tells crawlers which paths to skip with User-agent, Disallow and Allow lines, and can point to the sitemap.
| Item | Rule |
|---|---|
| URLs per sitemap | 50,000 maximum |
| Sitemap file size | 50 MB uncompressed maximum |
| URL format in sitemaps | Fully qualified, for example https://example.com/page |
| robots.txt location | Root of the host, for example https://example.com/robots.txt |
| robots.txt size read by Google | 500 KiB |
| Fields Google supports in robots.txt | user-agent, allow, disallow, sitemap |
Updated
Generators spit out a file, but they rarely explain why each line is there or what happens when two rules disagree. Every example below is annotated, and the builder turns a plain list of your pages into a valid sitemap with the special characters escaped for you.
Mini sitemap builder
Paste one full URL per line and the builder writes a valid urlset with special characters escaped.
Sitemap examples
Basic sitemap.xml
The xml declaration, the urlset with the protocol namespace, and one url per page. lastmod uses the W3C date format.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2026-10-01</lastmod>
</url>
<url>
<loc>https://example.com/services/roof-repair</loc>
<lastmod>2026-09-18</lastmod>
</url>
<url>
<loc>https://example.com/search?type=metal&area=north</loc>
</url>
</urlset>Sitemap index for large sites
Points to child sitemaps. Each child follows the same 50,000 URL and 50 MB limit.
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemaps/pages.xml</loc>
<lastmod>2026-10-01</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemaps/products-1.xml</loc>
</sitemap>
</sitemapindex>robots.txt examples
Allow everything and point to the sitemap
An empty Disallow means nothing is blocked. This is the right file for most small business sites.
User-agent: *
Disallow:
Sitemap: https://example.com/sitemap.xmlOnline shop: skip carts, accounts and filter combinations
Blocks URL patterns that create endless duplicates while keeping product and category pages open.
User-agent: *
Disallow: /cart
Disallow: /checkout
Disallow: /account/
Disallow: /*?sort=
Disallow: /*?*filter=
Allow: /account/help
Sitemap: https://shop.example.com/sitemap_index.xmlBlock a whole staging site
Stops compliant crawlers on a test copy. Add a password too, since this file only asks politely.
User-agent: *
Disallow: /Wildcards for file types
The dollar sign means the URL ends there, so /guide.pdf is blocked but /guide.pdf.html is not.
User-agent: Googlebot
Disallow: /*.pdf$
Disallow: /tmp/
User-agent: *
Disallow: /tmp/Which rule wins
| Rules | URL | Result | Why |
|---|---|---|---|
| Allow: /p and Disallow: / | /page | Allowed | /p is the longer match |
| Allow: /folder and Disallow: /folder | /folder/page | Allowed | Equal length, least restrictive wins |
| Disallow: /*.php$ | /index.php?x=1 | Allowed | The URL does not end in .php |
| Disallow: /fish | /Fish.html | Allowed | Paths are case-sensitive |
What each file is for
The sitemap is an invitation: here are the pages worth crawling and when they last changed. It helps most on new sites, large sites and pages that few internal links reach.
robots.txt is a set of crawl instructions, not a security tool. Anyone can read it, and badly behaved bots ignore it, so never rely on it to hide private areas. Protect those with a login.
How rules are matched
A crawler picks the group whose User-agent line matches it most specifically and ignores the rest. Googlebot with its own group will not read the rules under User-agent: *.
Paths are case-sensitive and match from the start. An asterisk stands for any run of characters and a dollar sign anchors the end of the URL, so Disallow: /*.pdf$ blocks every PDF.
How it works
- Paste one full URL per line into the builder and pick a lastmod date if you have one.
- Copy the generated XML into a file called sitemap.xml at your site root.
- Choose the robots.txt example closest to your setup and edit the paths.
- Add a Sitemap line to robots.txt and submit the sitemap in Search Console.
Tips
- Only list canonical URLs that return 200. Redirects, 404s and noindexed pages in a sitemap send mixed signals.
- Set lastmod to the date the main content really changed. Google uses it only when it is consistently accurate.
- Google ignores changefreq and priority, so you can leave them out.
- Blocking a page in robots.txt does not remove it from search. To keep a page out of results, allow crawling and add a noindex robots meta tag instead.
Frequently asked questions
Where should sitemap.xml go?
Anywhere on the same host works, but the root is the usual place because a sitemap generally covers only URLs at or below its own folder under the sitemaps.org protocol. Tell search engines where it is with a Sitemap line in robots.txt or by submitting it in Search Console.
How do I list more than 50,000 URLs?
Split them across several sitemap files and list those files in a sitemap index. The index uses sitemapindex and sitemap elements instead of urlset and url, and it can reference up to 50,000 sitemaps.
Does Google support Crawl-delay or Noindex in robots.txt?
No. Google reads only user-agent, allow, disallow and sitemap. Other crawlers may honour Crawl-delay, but Googlebot ignores it, and noindex has to go in a meta tag or X-Robots-Tag header.
What happens when Allow and Disallow both match a URL?
Google picks the most specific rule, meaning the one with the longest matching path. If two matching rules are equally specific, it uses the less restrictive one, which is Allow.
Do I need to escape characters in sitemap URLs?
Yes. A sitemap is XML, so an ampersand must be written as & and the other reserved characters as their entities. The file must also be UTF-8 encoded.
Related: XML sitemap generator, robots.txt generator, robots.txt tester, Sitemap checker, Next.js SEO checklist.
Build your site free or see all free tools. On We.Inc you can build your site free, with no card and no trial needed to start. AI building is on paid plans from $19 a month.
More in Guides
- Small Business SEO: A Plain-English Guide and Checklist (2026) | How-to Guide
- Soft 404: When a Page Says Not Found but the Server Says OK
- Single Page Application SEO: A Practical Guide
- SPF, DKIM and DMARC: The Three Records Behind Trusted Email
- SQL Joins Explained with Live Examples
- SSE vs WebSocket: Pick the Right Stream
- SSL Certificate Types: DV, OV, EV, Wildcard and SAN
- Static Site Generators Compared, with Measured Build Times
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App