# Sitemap in Robots.txt: How to Add It (and Fix "Sitemap.xml Not Indicated")

> Add one Sitemap line to robots.txt to fix the "sitemap.xml not indicated in robots.txt" warning. Exact syntax, multiple sitemaps, and robots.txt vs sitemap conflicts that block indexing.

Canonical: https://useneedle.net/blog/how-to-fix-sitemap-xml-not-indicated-in-robots-txt
Published: 2026-09-22
Last updated: 2026-10-21

**The fix:** add one line to the `robots.txt` file at the root of your domain:

```txt
Sitemap: https://example.com/sitemap.xml
```

Use the full URL, deploy, and re-run your audit. That clears the "sitemap.xml not indicated in robots.txt" warning.

The rest of this guide covers where that warning comes from, the syntax that trips people up, and the robots.txt and sitemap conflicts that do real damage to indexing.

## What the warning means

"Sitemap.xml not indicated in robots.txt" is a notice from SEO audit tools such as Semrush's Site Audit. It means your `robots.txt` has no `Sitemap:` line. Google Search Console doesn't report it, and on its own it won't stop pages being indexed.

It's still worth fixing. Crawlers read `robots.txt` before crawling a site, so a `Sitemap:` line there is the simplest way to tell every search engine, not just Google, where your list of URLs lives. Google can also find a sitemap you submit in Search Console. Bing and smaller crawlers often rely on the robots.txt line.

## robots.txt vs sitemap.xml: what each one does

The two files do opposite jobs, which is why they need to agree.

| | robots.txt | sitemap.xml |
|---|---|---|
| **Job** | Says which paths crawlers may or may not fetch | Lists the URLs you want discovered and indexed |
| **Location** | Always `/robots.txt` at the root of the host | Anywhere, as long as it's declared or submitted |
| **Typical contents** | `User-agent`, `Disallow`, `Allow`, `Sitemap` lines | A `<urlset>` of page URLs, or a `<sitemapindex>` of other sitemaps |
| **Does it control indexing?** | No. It controls crawling. A blocked page can still be indexed from links, without its content | No. It's a hint about which URLs matter |

To keep a page out of Google, use a `noindex` robots meta tag and **don't** block the page in robots.txt. If the page is blocked, Google never fetches it and never sees the `noindex`.

## How to add your sitemap to robots.txt

A typical robots.txt with a sitemap line:

```txt
User-agent: *
Disallow: /admin/
Disallow: /dashboard/

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

On Next.js with the App Router, `app/robots.js` (or `robots.ts`) generates this file. Return a `sitemap` field there instead of editing a static file.

### Syntax rules

1. **Use an absolute URL.** `Sitemap: /sitemap.xml` is not valid. Include `https://` and the domain.
2. **Use your canonical host and protocol.** If your site lives at `https://example.com`, don't point to `http://` or `www.`. A sitemap URL that redirects adds a step that some crawlers skip.
3. **Position doesn't matter.** The `Sitemap:` line isn't tied to any `User-agent` group, so it can go anywhere. The convention is the end of the file.
4. **Case.** Google treats the field name as case-insensitive, but the URL itself is case-sensitive. Write `Sitemap:` with a capital S to be safe with every crawler.
5. **One URL per line.** Add a separate `Sitemap:` line for each sitemap.

### Multiple sitemaps or a sitemap index

If your site has a sitemap index file that points to other sitemaps, list just the index:

```txt
Sitemap: https://example.com/sitemap-index.xml
```

Or list each sitemap on its own line:

```txt
Sitemap: https://example.com/sitemap-posts.xml
Sitemap: https://example.com/sitemap-products.xml
```

## Robots.txt and sitemap conflicts that hurt indexing

The missing `Sitemap:` line is the mild problem. These are the ones that keep pages out of Google:

1. **Sitemap URLs blocked by robots.txt.** Your sitemap asks Google to index `/pricing`, and robots.txt says `Disallow: /pricing`. Search Console flags these as blocked by robots.txt. Decide which file is wrong and fix that one.
2. **A leftover `Disallow: /`.** Staging sites often block everything. If that robots.txt ships to production, crawling stops across the whole site.
3. **Blocking pages you want removed.** If you add `noindex` to a page and also disallow it, Google can't see the `noindex`, and the URL can stay in results.
4. **Blocking CSS or JavaScript.** If Google can't fetch the files a page needs to render, it may misread the page. Leave `/_next/`, `/static/` and similar asset paths crawlable.
5. **Sitemap listing URLs that redirect or 404.** Only list final, canonical URLs that return `200`. A sitemap full of redirects tells Google the file isn't maintained.

## Check your setup

After deploying:

1. Open `https://yourdomain.com/robots.txt` in a browser and confirm the `Sitemap:` line is there with the right URL.
2. Run the [Google Indexing Checker](https://useneedle.net/tools/google-indexing-checker). It fetches your robots.txt, lists its `Sitemap:` lines, flags disallow rules that apply to all crawlers, and checks whether `/sitemap.xml` is reachable and declared.
3. Run the [Sitemap Validator](https://useneedle.net/tools/sitemap-validator) to confirm the sitemap is valid XML, see how many URLs it lists, and check `lastmod` and content type.
4. In Google Search Console, submit the sitemap under **Sitemaps** and watch its status. Our guide on [how to check a website's sitemap](https://useneedle.net/blog/sitemap-validation-crawlability-checks) explains each status.

Both tools are free and need no sign-up.

## Next: AI crawlers

The same robots.txt also decides whether AI crawlers such as GPTBot, ClaudeBot and PerplexityBot can read your site. See our [guide to llms.txt and AI crawlers](https://useneedle.net/blog/llms-txt-ai-crawlers-geo-guide) for what to allow and why.

## FAQ

### What does "sitemap.xml not indicated in robots.txt" mean?

It means your robots.txt file has no Sitemap line pointing to your XML sitemap. It is a notice from SEO audit tools such as Semrush, not an error reported by Google Search Console. Adding a line like "Sitemap: https://example.com/sitemap.xml" to robots.txt clears it.

### How do I add a sitemap to robots.txt?

Open the robots.txt file at the root of your domain and add a line that starts with "Sitemap:" followed by the full URL of your sitemap, including https:// and the domain. You can add it anywhere in the file and repeat it for several sitemaps.

### Do I need the sitemap in robots.txt if I submitted it in Search Console?

Not strictly for Google, because a sitemap submitted in Search Console is already known. The robots.txt line still helps Bing and other crawlers find it, costs nothing, and keeps audit tools quiet.

### Is the Sitemap directive case-sensitive?

Google treats robots.txt field names as case-insensitive, so "sitemap:" works. The URL after it is case-sensitive, though. Writing "Sitemap:" is the common convention and the safest choice for other crawlers.

### Can robots.txt and my sitemap conflict?

Yes. If your sitemap lists a URL that robots.txt disallows, you are asking Google to index a page it is not allowed to crawl. Search Console reports these as blocked by robots.txt. Remove the URL from the sitemap or the rule from robots.txt, depending on which one is wrong.

---

From Needle (https://useneedle.net). HTML version: https://useneedle.net/blog/how-to-fix-sitemap-xml-not-indicated-in-robots-txt
