Blogs

XML Sitemaps and Robots.txt: A Beginner’s Guide

XML Sitemaps and Robots.txt A Beginner's Guide
Table of Contents

If you’re new to technical SEO, two files you’ll encounter very quickly are sitemap.xml and robots.txt.

They look simple.

One is an XML file containing URLs. The other is a small text file containing crawler instructions.

But these files can have a surprisingly large impact on how search engines discover and crawl a website.

A properly configured sitemap can help Google discover important URLs, particularly on larger websites, newer sites, and sites where some pages are not well connected through internal links. A correctly configured robots.txt file can help manage crawler access and reduce unnecessary crawling. Google describes the two roles quite clearly: sitemaps encourage discovery and crawling, while robots.txt controls which URLs crawlers can access.

The problem is that they’re also frequently misunderstood.

A sitemap does not force Google to index a page.

Robots.txt does not reliably remove a page from Google.

And putting every URL on your website into a sitemap isn’t necessarily good SEO.

In this guide, we’ll explain how both files work, how they differ, how to configure them correctly, and what WordPress website owners should check before submitting them to Google.


Part 1: What Is an XML Sitemap?

Let’s start with the easier one.

An XML sitemap is a file that lists URLs you want search engines to discover and consider for crawling.

A simple sitemap might look like this:

<?xml version="1.0" encoding="UTF-8"?><urlsetxmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://example.com/</loc><lastmod>2026-08-18</lastmod></url><url><loc>https://example.com/services/</loc><lastmod>2026-08-15</lastmod></url><url><loc>https://example.com/contact/</loc><lastmod>2026-08-10</lastmod></url></urlset>

You don’t normally need to create this manually.

Most modern content management systems and SEO tools can generate sitemaps automatically. Google specifically notes that CMS platforms such as WordPress commonly make sitemaps available automatically.

What information does a sitemap contain?

The most important element is:

<loc>

This contains the complete URL.

You may also see:

<lastmod>

which tells search engines when the page was last significantly modified.

Google says it can use an accurate and consistently verifiable lastmod value. However, Google ignores priority and changefreq values, so adding arbitrary values such as:

<priority>1.0</priority><changefreq>daily</changefreq>

doesn’t give you an SEO advantage in Google.

That’s important because many older sitemap tutorials still recommend these fields as if they influence Google’s crawling decisions.

They don’t.


Do all websites need an XML sitemap?

Not necessarily.

A very small website with excellent internal linking may be discoverable without one.

Google says that sitemaps are particularly useful for larger sites, new sites, sites with poorly linked pages, and websites containing specialized content such as images or videos.

For a business website, however, there is usually little downside to maintaining a clean sitemap.

If you’re running WordPress, your SEO plugin or WordPress itself may already generate one.

The important thing is not simply having a sitemap.

It’s making sure the sitemap contains the right URLs.


What should go into an XML sitemap?

Generally, include URLs that are:

  • Canonical
  • Indexable
  • Publicly accessible
  • Returning a successful HTTP response
  • Valuable to search users
  • URLs you actually want appearing in Google

For example:

https://example.com/https://example.com/about/https://example.com/services/https://example.com/services/seo/https://example.com/blog/https://example.com/blog/technical-seo-guide/

Google’s current sitemap documentation recommends including the URLs you want to see in search results and using the canonical versions of URLs.


What shouldn’t go into your sitemap?

Avoid adding URLs such as:

https://example.com/cart/https://example.com/checkout/https://example.com/my-account/

if they aren’t intended to appear in search.

Also review:

  • Redirect URLs
  • 404 pages
  • 410 pages
  • Noindex pages
  • Duplicate URLs
  • Temporary URLs
  • Internal search results
  • Unimportant filter URLs
  • Tracking parameter URLs

A sitemap should not become a complete dump of every URL your website can generate.

Think of it as a curated list of important URLs, not a database export.


Sitemap size limits

Google currently supports up to:

50,000 URLs or 50 MB uncompressed per sitemap file.

If your website exceeds those limits, split the URLs into multiple sitemap files and optionally use a sitemap index.

For example:

sitemap_index.xml│├── post-sitemap.xml├── page-sitemap.xml├── product-sitemap.xml└── category-sitemap.xml

This structure is particularly common on larger WordPress websites.


Part 2: What Is Robots.txt?

Now let’s look at the other file.

A robots.txt file tells crawlers which URLs they are allowed or not allowed to access.

It is normally located at:

https://example.com/robots.txt

Google describes robots.txt as a mechanism for managing crawler access and traffic, not as a method for keeping pages out of Google’s search index.

A simple robots.txt file could look like:

User-agent: *Disallow:

This essentially says that there are no disallowed paths for crawlers matching *.

A more specific example:

User-agent: *Disallow: /wp-admin/

This tells compliant crawlers not to crawl URLs under /wp-admin/.


Understanding User-agent

The User-agent identifies the crawler to which the rule applies.

For example:

User-agent: *

means the rule applies broadly to crawlers.

You can also target a particular crawler:

User-agent: GooglebotDisallow: /private/

However, don’t start creating complicated crawler-specific rules unless you have a genuine reason.

For most small websites, a simple configuration is safer.


Understanding Disallow

This:

Disallow: /private/

means:

Don’t crawl URLs under /private/.

This:

Disallow: /wp-admin/

means:

Don’t crawl URLs under /wp-admin/.

And:

Disallow:

means:

Nothing is disallowed by this rule.


Understanding Allow

You can also explicitly allow a path.

For example:

User-agent: *Disallow: /private/Allow: /private/public-page/

This creates a more specific exception.

But be careful.

The more complicated your robots.txt becomes, the easier it is to introduce conflicting rules.


The Most Important Difference: Crawling vs Indexing

This is where many beginners make mistakes.

Robots.txt

Controls:

Can a crawler access this URL?

Noindex

Controls:

Should this page be included in search results?

Sitemap

Communicates:

Here are the URLs I consider important and want search engines to discover.

These are three different functions.

Google explicitly warns against using robots.txt as a mechanism for keeping pages out of Google Search. A blocked URL can still potentially appear in search results if Google discovers the URL through other sources.

If you want a publicly accessible HTML page removed from search, a noindex directive is generally the appropriate mechanism, provided Google can crawl the page and see that directive.

For example:

<metaname="robots"content="noindex">

Why You Shouldn’t Use Robots.txt for Noindex

Imagine you write:

User-agent: *Disallow: /old-page/

and then add:

<metaname="robots"content="noindex">

to /old-page/.

It looks logical.

But Google can’t crawl /old-page/ because robots.txt blocks it.

Therefore, Google may never see the noindex instruction.

Google specifically explains that a crawler must be able to access the page to see and process the noindex directive.

So the correct approach depends on your objective.

Want to manage crawling?

Use:

robots.txt

Want to prevent indexing?

Use:

noindex

Want Google to discover important URLs?

Use:

XML sitemap + internal links


Part 3: How XML Sitemaps and Robots.txt Work Together

These files are not competitors.

They work together.

Imagine your website contains 1,000 URLs.

You might want Google to focus on:

/services//about/contact/blog/products/

while avoiding unnecessary crawling of certain areas.

Your robots.txt might contain:

User-agent: *Disallow: /wp-admin/Disallow: /private/Disallow: /internal-search/Sitemap: https://example.com/sitemap.xml

Your sitemap might contain:

https://example.com/https://example.com/about/https://example.com/services/https://example.com/services/seo/https://example.com/services/web-development/https://example.com/blog/

The sitemap says:

Here are the important URLs.

Robots.txt says:

Here are areas crawlers should not access.

That’s the basic relationship.

Google’s technical SEO guidance summarizes the distinction well: use robots.txt rules to prevent crawling and sitemaps to encourage crawling/discovery.


Adding Your Sitemap to Robots.txt

You can reference your sitemap inside robots.txt:

User-agent: *Disallow: /wp-admin/Sitemap: https://example.com/sitemap.xml

Google supports sitemap declarations in robots.txt and says you can list multiple sitemaps.

This is useful because crawlers can discover your sitemap while fetching robots.txt.

You can still submit the sitemap directly through Google Search Console.


Should You Submit Your Sitemap to Google?

Yes.

If you have access to Google Search Console, submitting your sitemap gives you useful visibility into whether Google can fetch and process it.

Go to:

Google Search Console → Sitemaps

Enter:

sitemap.xml

or:

sitemap_index.xml

depending on your website.

Google notes that submitting a sitemap is a hint, not a guarantee that Google will download it or crawl every URL within it.

That’s an important distinction.

Submitting:

https://example.com/sitemap.xml

doesn’t mean:

Google must index everything inside this file.

It means:

Google, these are the URLs I consider important and would like you to discover.

Google still decides what to crawl, index and rank.


Sitemap vs Internal Links

Don’t make the mistake of thinking your sitemap replaces internal linking.

It doesn’t.

Suppose you have:

Homepage   ↓Services   ↓SEO Services

and then:

/blog/technical-seo/

isn’t linked anywhere.

Putting the blog post in your sitemap helps Google discover it.

But internal links help Google understand how that page fits into the site’s structure.

A strong technical SEO setup uses both:

Internal links + XML sitemap

not:

XML sitemap instead of internal links.

Google’s documentation explains that sitemaps help discovery, while normal crawlable links remain an important way for Google to find pages.


Part 4: WordPress Sitemap and Robots.txt Setup

WordPress makes this relatively easy.

Modern WordPress installations can provide a sitemap automatically, and SEO plugins may also generate sitemap indexes and provide controls for which content types should be included. Google notes that CMS platforms such as WordPress commonly generate sitemaps automatically.

Depending on your setup, you may see something like:

https://example.com/wp-sitemap.xml

or a plugin-generated:

https://example.com/sitemap_index.xml

Don’t assume both should be submitted.

First determine which sitemap your website actually uses.


WordPress sitemap checklist

Open your sitemap in a browser.

Check:

  • Does it load?
  • Are the URLs correct?
  • Are they canonical?
  • Are there unexpected post types?
  • Are noindex pages included?
  • Are redirects included?
  • Are old URLs still present?
  • Are important pages missing?

For example, if your SEO plugin generates:

post-sitemap.xmlpage-sitemap.xmlcategory-sitemap.xml

review each sitemap type.

You don’t necessarily want every taxonomy or custom post type indexed.


WordPress robots.txt

Depending on your WordPress setup, your robots.txt may be generated dynamically or managed through an SEO plugin/server configuration.

A simple business website might use something similar to:

User-agent: *Disallow: /wp-admin/Disallow: /wp-login.phpSitemap: https://example.com/sitemap_index.xml

However, don’t copy this blindly.

For example, /wp-admin/admin-ajax.php may be used by legitimate front-end functionality.

Elementor, WooCommerce and other plugins can depend on AJAX requests.

So you shouldn’t block large WordPress paths simply because they look technical.

Before adding a Disallow, understand what the URL does.


What About CSS and JavaScript?

This is another area where old SEO advice causes problems.

Some older robots.txt files contain rules such as:

Disallow: /wp-content/

That can be dangerous.

Your website’s CSS, JavaScript, images and other resources may live inside directories that a broad rule could block.

Google says that if important resources are blocked, it may prevent Google from properly understanding and rendering the page.

So don’t block entire directories just because they contain technical files.


What About AI Crawlers?

Robots.txt can also contain rules for non-search crawlers, including AI-related crawlers.

But don’t add AI crawler blocks automatically.

Whether you allow or disallow a particular crawler is a business and content-usage decision, not a universal SEO requirement.

If your goal is to maximize visibility across AI-powered search and answer systems, unnecessarily blocking relevant crawlers may work against that objective.

Also remember that robots.txt is only one layer. CDN/WAF rules, server-level controls and application-level restrictions can independently block crawlers.

For websites using Cloudflare or another CDN, check those controls as well rather than assuming robots.txt tells the whole story.


Part 5: Common Sitemap and Robots.txt Mistakes

Most problems don’t happen because someone doesn’t have these files.

They happen because someone configured them incorrectly.

Mistake 1: Blocking the entire website

This is one of the most serious errors.

User-agent: *Disallow: /

That tells compliant crawlers not to crawl the entire site.

This can happen accidentally during development.

Always check robots.txt after:

  • Website migration
  • Redesign
  • Hosting migration
  • Staging-to-live deployment
  • CDN configuration
  • SEO plugin changes

Mistake 2: Putting noindex pages in the sitemap

Suppose you have:

<metaname="robots"content="noindex">

on:

/thank-you/

but your sitemap includes:

https://example.com/thank-you/

That’s an inconsistent setup.

Your sitemap should generally contain the canonical, indexable URLs you want in Google.

Google recommends including the URLs you want in search results and using canonical URLs in the sitemap.


Mistake 3: Blocking a URL and expecting it to disappear from Google

This is a classic misunderstanding.

You add:

Disallow: /old-page/

and expect Google to remove it immediately.

But robots.txt doesn’t guarantee removal.

Google explains that a blocked URL may still be indexed if it is discovered through other sources.

If you need the page removed from search, use the appropriate indexing/removal method.


Mistake 4: Using robots.txt for canonicalization

Don’t do this.

Robots.txt isn’t a canonicalization tool.

Google specifically advises against using robots.txt for canonicalization because blocked URLs can still be indexed without their content.

Use:

<linkrel="canonical"href="https://example.com/preferred-url/">

where appropriate.

And keep the preferred canonical URLs in your sitemap.


Mistake 5: Putting every URL into the sitemap

More URLs don’t mean more SEO.

Imagine an eCommerce site creates:

/product/shoes/

and thousands of URLs from:

?color=black?size=10?sort=price?brand=nike

Putting all of them into the sitemap can create a messy crawling environment.

The sitemap should represent the URLs you actually want search engines to discover and consider.


Mistake 6: Using fake lastmod dates

Don’t update every URL’s:

<lastmod>

every day just to make Google crawl it.

Google says it can use lastmod when it is consistently and verifiably accurate.

If a page genuinely changed significantly on:

2026-08-18

then use that date.

Don’t pretend every page changed simply because your sitemap generator ran.


Mistake 7: Assuming a sitemap guarantees indexing

It doesn’t.

This is perhaps the biggest misconception.

You can have:

Perfect sitemap+Perfect robots.txt

and still have pages that aren’t indexed.

Why?

Because indexing depends on much more than discovery.

Google still evaluates:

  • Accessibility
  • Indexability
  • Canonicalization
  • Content
  • Quality
  • Duplication
  • Search relevance
  • Overall website signals

Google explicitly states that sitemap submission doesn’t guarantee that URLs will be crawled or indexed.


A Practical SEO Setup for a Small WordPress Business

For a typical small business website, keep things simple.

robots.txt

User-agent: *Disallow: /wp-admin/Disallow: /wp-login.phpSitemap: https://example.com/sitemap_index.xml

Then ensure:

Sitemap

Contains:

HomepageAboutServicesImportant service pagesBlog postsRelevant categoriesProductsImportant landing pages

And excludes unnecessary:

Admin pagesCheckoutCartAccount pagesThank-you pagesInternal searchTemporary URLsNoindex pagesRedirect URLsDuplicate URLs

This isn’t a universal copy-and-paste configuration. Your actual site architecture should determine the rules.


XML Sitemap and Robots.txt Audit Checklist

Use this checklist during a technical SEO audit.

Sitemap

  • Sitemap loads successfully
  • Sitemap uses HTTPS
  • URLs are absolute
  • URLs return 200 where appropriate
  • URLs are canonical
  • Noindex URLs aren’t included
  • Redirect URLs aren’t included
  • 404 URLs aren’t included
  • Important pages are included
  • Sitemap is under size limits
  • lastmod values are accurate
  • Sitemap submitted to Search Console

Robots.txt

  • /robots.txt loads
  • No accidental Disallow: /
  • Important pages aren’t blocked
  • CSS isn’t unnecessarily blocked
  • JavaScript isn’t unnecessarily blocked
  • Images aren’t unintentionally blocked
  • WordPress functionality isn’t broken
  • Sitemap URL is referenced
  • Rules are documented
  • CDN/WAF rules have also been checked

Search Console

  • Sitemap processed successfully
  • Sitemap errors reviewed
  • Page Indexing report reviewed
  • URL Inspection tested
  • Important pages are indexable
  • Robots.txt blocking issues investigated
  • Canonical issues checked

XML Sitemap vs Robots.txt: Quick Comparison

Feature XML Sitemap Robots.txt
Main purpose Help discovery Control crawling
File type XML Plain text
Typical URL /sitemap.xml /robots.txt
Lists URLs Yes No
Blocks crawling No Yes
Guarantees indexing No No
Controls indexing No No
Can reference sitemap N/A Yes
Useful for large websites Very useful Very useful
Useful for WordPress Yes Yes
Should contain canonical URLs Yes N/A

The simplest way to remember it is:

Sitemap = “Here are the important URLs.”

Robots.txt = “Here are the areas crawlers should not access.”

Noindex = “Don’t include this page in search results.”

Once you understand that distinction, technical SEO becomes much easier.


Final Thoughts

XML sitemaps and robots.txt are small files, but they play an important role in technical SEO.

A sitemap helps search engines discover the URLs you consider important.

Robots.txt helps manage crawler access.

Neither one is a magic ranking tool.

A sitemap doesn’t make weak content rank.

Robots.txt doesn’t improve rankings by itself.

And neither file replaces:

  • Good site architecture
  • Internal linking
  • Useful content
  • Correct canonicalization
  • Strong technical SEO
  • Proper indexing controls

The best setup is usually a clean one.

Give Google a clear path to your important pages.

Don’t waste crawling on unnecessary URLs.

Don’t accidentally block important resources.

Don’t put non-indexable URLs into your sitemap.

And don’t use robots.txt as a substitute for noindex.

For WordPress websites, this becomes particularly important as the site grows and starts generating more URLs through plugins, taxonomies, WooCommerce, filters and dynamic functionality.

A few minutes spent checking these files can prevent a surprisingly serious SEO problem.

And if you’re troubleshooting an indexing issue, start with the basics:

Check robots.txt.

Check the sitemap.

Check the canonical.

Check noindex.

Check Google Search Console.

Then fix the actual problem instead of repeatedly requesting indexing.

That’s the foundation of a clean technical SEO setup in 2026.


Frequently Asked Questions

1. What is an XML sitemap?

An XML sitemap is a file that lists important URLs on a website and provides information that can help search engines discover and crawl those URLs. Google supports XML sitemaps and recommends using canonical URLs that you want considered for search.

2. What is robots.txt?

Robots.txt is a plain-text file that provides crawler access instructions for URLs on a website. It is primarily used to manage crawling rather than to remove pages from Google’s search index.

3. What is the difference between sitemap.xml and robots.txt?

A sitemap communicates which URLs you consider important for discovery, while robots.txt tells crawlers which URLs or paths they should not access. They serve different purposes and are often used together.

4. Does every website need an XML sitemap?

Not every website technically needs one. Small websites with strong internal linking may be discovered without a sitemap. However, sitemaps can be particularly useful for large, new or poorly linked websites and for specialized content.

5. Does robots.txt stop Google from indexing a page?

Not reliably. Robots.txt prevents crawling, but Google may still know about a blocked URL and potentially show it in search results. If you need to prevent a page from appearing in Google, use an appropriate noindex directive while allowing Google to crawl the page.

6. Can I put noindex in robots.txt?

No. Google does not support noindex as a robots.txt rule. Use a robots meta tag or an X-Robots-Tag HTTP response header instead.

7. Where should robots.txt be located?

For a website such as example.com, robots.txt should normally be available at:

https://example.com/robots.txt

It applies to the host where it is located.

8. Where should my XML sitemap be located?

A sitemap can technically be hosted in different locations, but Google recommends placing it at the site root when appropriate. You can also submit it directly through Google Search Console.

9. Does submitting a sitemap guarantee indexing?

No. Sitemap submission is a hint to Google and does not guarantee that Google will crawl or index every URL listed.

10. Should robots.txt contain my sitemap URL?

It is good practice to reference your sitemap in robots.txt. Google supports the Sitemap: directive, and you can list multiple sitemap URLs.

11. Should noindex pages be included in a sitemap?

Generally, no. Your sitemap should normally contain canonical URLs that you want search engines to consider for search results.

12. Can robots.txt affect SEO?

Yes. Incorrect robots.txt rules can prevent crawlers from accessing important pages or resources. Google warns that blocking important resources can interfere with its ability to properly understand a page.

13. Does WordPress automatically create a sitemap?

Modern WordPress installations can provide a sitemap automatically, and WordPress SEO plugins can also generate sitemap indexes. Google notes that CMS platforms such as WordPress commonly make sitemaps available.

14. Should I block /wp-admin/ in robots.txt?

It is common to prevent crawler access to the WordPress admin area, but you should understand your site’s setup before changing robots.txt. Don’t apply broad WordPress blocks that could interfere with legitimate front-end resources or functionality.

15. Should I block CSS and JavaScript in robots.txt?

Generally, don’t block important CSS or JavaScript resources without a specific reason. Google needs access to important resources to properly understand and render pages.

16. How often should I update my sitemap?

Ideally, your sitemap should update automatically when important URLs are created, removed or substantially changed. Use accurate lastmod dates rather than changing dates simply to encourage crawling. Google says it can use accurate and verifiable lastmod information.

17. Can a sitemap improve SEO rankings?

A sitemap doesn’t directly guarantee better rankings. Its primary value is helping search engines discover URLs and understand which URLs you consider important. Rankings still depend on many other factors.

18. Can I have multiple XML sitemaps?

Yes. Large websites can use multiple sitemap files and a sitemap index. Google currently allows up to 50,000 URLs or 50 MB uncompressed per sitemap file.

Picture of Nizwas IT Solutions Team

Nizwas IT Solutions Team

Reviewed by the Nizwas IT Solutions SEO team, 8+ years of building, optimizing, maintaining, and ranking WordPress websites for businesses across multiple international markets.

Recent Posts

Send Us a Message

Have a project in mind or a question about SEO, web design, or digital marketing? Tell us about your business and goals. Our team replies within 24 hours, wherever in the world you’re based.

By submitting, you agree to be contacted by Nizwas IT Solutions regarding your enquiry.

Share this article:

Call Us Email Us Chat with Us
Get Free Quote