XML Sitemap and Robots.txt Guide for WordPress Websites

XML Sitemap and Robots.txt Guide for WordPress Websites

Quick answer: An XML sitemap lists the pages you want Google to index, and robots.txt tells crawlers which paths to skip. On WordPress, let your SEO plugin generate the sitemap, include only canonical, indexable pages, add a Sitemap: line to robots.txt, block low value paths like internal search and the cart, never block CSS or JavaScript, and submit the sitemap in Google Search Console.

Key takeaways

  • A sitemap helps discovery, but it does not force Google to index a page.
  • robots.txt controls crawling, not indexing. Use noindex to keep a page out of results.
  • Only list URLs that return a 200 status, are canonical and are not noindexed.
  • One wrong line in robots.txt can block your whole site from Google.
  • Submit your sitemap once in Search Console and check its report monthly.
XML sitemap and robots.txt guide for WordPress websites with Google Search Console submission
Your sitemap and robots.txt guide how Google crawls your site

What is an XML sitemap?

An XML sitemap is a file that lists the URLs on your site you want search engines to find, often with the date each was last updated. Since WordPress 5.5 there is a basic built in sitemap at /wp-sitemap.xml. Most SEO plugins, including SmartCrawl, Yoast and Rank Math, replace it with a better one, usually at /sitemap.xml or /sitemap_index.xml.

Sitemaps matter most for new sites, large sites, and pages with few internal links. They are also how Google learns quickly that you have published or updated something.

What is robots.txt?

robots.txt is a plain text file in the root of your domain that tells crawlers which paths they may or may not request. It is the first file Googlebot checks when it visits. WordPress creates a virtual robots.txt if no real file exists, and SEO plugins let you edit it from the dashboard.

Comparison table of an XML sitemap versus a robots.txt file showing what each does, where it lives and common mistakes
The two files do different jobs and work best together

What to include in your sitemap

  • Pages, posts, products and categories you want to rank.
  • Only URLs that return a 200 status, not redirects or 404s.
  • Only the canonical version of each page. See how to fix duplicate content with canonical tags.
  • No noindex pages, thank you pages, tag archives or attachment pages.
  • An accurate lastmod date that changes only when content genuinely changes.

A sensible WordPress robots.txt

Most small business WordPress sites need very little in robots.txt. Here is a safe starting point:

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /?s=
Disallow: /search/

Sitemap: https://www.example.com.au/sitemap_index.xml

WooCommerce stores can also disallow /cart/, /checkout/ and /my-account/, although WooCommerce already sets these to noindex. If you want to manage AI crawlers such as GPTBot, robots.txt is where you allow or block them, and it pairs well with an llms.txt file. See what is llms.txt.

Comparison of what to block and what to allow in a WordPress robots.txt file
Block low value paths, never your CSS, scripts or key pages

How to submit your sitemap to Google

Five steps to submit an XML sitemap to Google Search Console: find it, clean it, reference it in robots.txt, submit and monitor
Submitting a clean sitemap speeds up discovery of new pages
  1. Open your sitemap URL in a browser and confirm it loads.
  2. Sign in to Google Search Console and select your property. If you do not have one yet, follow the Google Analytics and Search Console setup guide.
  3. Go to Indexing, then Sitemaps.
  4. Enter the sitemap path, for example sitemap_index.xml, and press Submit.
  5. Check the status shows Success and note the number of discovered pages.
  6. Repeat in Bing Webmaster Tools, which can import straight from Search Console.

Common sitemap and robots.txt mistakes

  • "Discourage search engines" left ticked: under Settings then Reading in WordPress, this adds a noindex to the whole site. It is often left on after a site launches from staging.
  • Disallow: / on the live site: a staging robots.txt copied across blocks everything.
  • Blocking CSS and JavaScript: Google needs these to render your pages and judge mobile friendliness.
  • Two sitemaps from two plugins: pick one SEO plugin and disable the other sitemap.
  • Using robots.txt to hide a page: a blocked URL can still appear in results if other sites link to it. Use noindex instead, and do not block it in robots.txt or Google will never see the noindex.
  • Sitemap full of junk: redirected, noindexed and 404 URLs make Google trust your sitemap less.

Check your sitemap is working

In Search Console, the Sitemaps report shows when Google last read the file and how many URLs it found. The Pages report then shows which of those were indexed and why others were not. If important pages are listed as "Discovered, currently not indexed" or "Crawled, currently not indexed", the problem is usually content quality or weak internal links rather than the sitemap itself. The website not showing on Google guide and internal linking strategy guide help with both.

Need your sitemap and robots.txt fixed?

My WordPress XML Sitemap and Robots.txt Fix cleans your sitemap of junk URLs, writes a safe robots.txt, removes conflicting plugin output and submits everything to Google Search Console and Bing for a fixed A$149. It is delivered online for businesses in Australia, New Zealand, the United States and Canada.

Related services: Google Search Console setup and indexing fix, WordPress SEO plugin setup and llms.txt and AI crawler setup.

Frequently asked questions

Where is my WordPress sitemap?

Try yourdomain.com.au/sitemap_index.xml, /sitemap.xml or /wp-sitemap.xml. Your SEO plugin settings also show the exact sitemap URL.

Does robots.txt stop a page being indexed?

No. robots.txt only stops crawling. A blocked page can still be indexed if other pages link to it. To keep a page out of Google, allow crawling and add a noindex tag.

How often should I resubmit my sitemap?

Once is enough. Google rereads submitted sitemaps regularly. Resubmit only if the sitemap URL changes, for example after switching SEO plugins.

Should I block AI crawlers in robots.txt?

It depends on your goals. Blocking crawlers such as GPTBot can stop your content being used by those tools, but it may also reduce your visibility in AI answers. Most small businesses benefit from allowing them.

Why does Search Console say my sitemap could not be read?

Common causes are a typo in the URL, a caching or security plugin blocking the file, a 404 after changing SEO plugins, or a firewall rule blocking Googlebot.

Back to blog
Get in touch

Have a project in mind?

Tell me about your idea. I'll get back to you with honest advice and a clear quote.

  • Talk directly to the developer
  • Clear quotes before any work starts
  • Sydney CBD based
Contact us