Losing clicks to competitors? Find out exactly why, and what to fix first.

Show me why
Skip to content

Technical SEO

How to Add a Sitemap to Robots.txt

Add saadrazaseo.com as a preferred source on Google

No pressure and no sales script. Just honest answers.

To add a sitemap to robots.txt, put a line that starts with Sitemap: followed by the full, absolute URL of your sitemap file anywhere in the file. Search engines read it when they fetch robots.txt, so it helps them discover your sitemap even if you have not submitted it elsewhere.

The exact format

Sitemap: https://www.example.com/sitemap.xml

The URL must be complete, including https and the domain. A relative path such as /sitemap.xml is not valid for this directive.

Where the line goes

The Sitemap line is independent of user-agent groups. You can place it at the top or bottom of the file and it applies regardless of which bot rules sit around it. Most people put it at the end so the file stays easy to read.

Not sure if this is hurting your site?

Get the fixes that matter most, in priority order.

Find my blockers

Adding more than one sitemap

List each sitemap on its own line, or point to a single sitemap index file that references the others.

Sitemap: https://www.example.com/sitemap-pages.xml
Sitemap: https://www.example.com/sitemap-posts.xml

Does this replace Search Console?

No. Submitting the sitemap in Google Search Console still gives you reporting on discovered and indexed URLs. The robots.txt line is a complementary signal that also works for other search engines. For the basics of the file itself, read what an XML sitemap is and how to submit one.

Common mistakes

  • Using a relative URL instead of a full one.
  • Pointing to a sitemap on a different protocol or host than the site actually uses.
  • Listing a sitemap that returns an error or redirects.
  • Blocking the sitemap URL itself with a Disallow rule.

Before you publish, build a clean file with my free robots.txt generator, create the sitemap with the XML sitemap generator and confirm it is valid using the sitemap validator.

Frequently asked questions

Can I add a sitemap to robots.txt on a different domain?

The directive supports full URLs, but keep it simple and use sitemaps on your own domain to avoid confusion.

Is the Sitemap line case sensitive?

The directive name is not, but the URL after it is, so copy it exactly.

Next steps

Once the file is live, test it with the robots.txt tester. If you want a technical review of your site, contact me here.

More in this series (robots.txt questions): start with Free Robots.txt Generator, then explore:

Is this holding your site back?

Share your website and I will look at the technical issues holding it back.

Your details are only used to reply to your request. No spam.

Grow my trafficCall