How do I reference my sitemap in robots.txt?

Last updated: September 11, 2020

It’s a best practice to always reference your XML sitemap(s) in your robots.txt file.

Here are the rules of engagement:

  • Reference the absolute URL to your XML sitemap
  • You can reference multiple XML sitemaps
  • You can rerence regular XML sitemaps, and XML sitempap indices
  • You can reference XML sitemaps on another domain, meaning: if your domain is example.com and your XML sitemap is on example2.com then you can reference that domain.

On top of this, we always recommend also submitted your XML sitemaps through Google Search Console and Bing Webmaster Tools.

XML sitemap correctly referenced

In this example, XML sitemaps are correctly referenced:

User-agent: *
Disallow:

Sitemap: https://www.example.com/people.xml
Sitemap: https://www.example.com/companies.xml
Sitemap: https://www.example.com/blog-posts.xml
Sitemap: https://www.example.com/reviews.xml

XML sitemap incorrectly referenced

In this example, the XML sitemap is — incorrectly — referenced using a relative URL:

User-agent: *
Disallow:

Sitemap: /pages.xml

XML sitemap correctly referenced, but disallowed

In this example, the XML sitemap is correctly referenced but search engines won’t be able to access it because of the Disallow: / directive:

User-agent: *
Disallow: /

Sitemap: https://www.example.com/pages.xml
Sitemap: https://www.example.com/posts.xml
ContentKing Academy

Read the full Academy article to learn everything about Robots.txt

Start your free trial

Get up and running in 20 seconds

Please enter a valid domain name (www.example.com).
  • No credit card required
  • No installation needed
  • No strings attached