How do I reference my sitemap in robots.txt?

Last updated: August 6, 2021

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 submitting your XML sitemaps through Google Search Console and Bing Webmaster Tools.

Are you correctly referencing the XML sitemap in your robots.txt?

Audit your robots.txt and find out right away!

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

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