Technical SEO
robots.txt and XML sitemaps for SaaS websites
Configure robots.txt and XML sitemaps without leaking private routes or accidentally blocking the public pages that should rank.
robots.txt and an XML sitemap solve different problems. robots.txt tells crawlers which paths not to fetch; the sitemap hands search engines a list of canonical public URLs. Neither file keeps a private page private.
On SaaS sites the usual mistake is mixing the marketing site with the logged-in product. Public guides belong in the sitemap. Account, billing, internal API, and dashboard routes usually do not. When the two files contradict each other, Search Console tells you, and the fixes for each "blocked by robots.txt" message are below.
Use robots.txt for crawl guidance, not access control
A disallowed path is still public. Anyone can read robots.txt, and Google can still show a blocked URL in results when other pages link to it. Protect sensitive routes with authentication and authorization. Use noindex on a public page when the goal is to keep that page out of search results.
Listing /admin or /dashboard in robots.txt also tells everyone those routes exist. ScanMySaaS reports this as a low finding. It is acceptable when the routes sit behind authentication. Our own robots.txt disallows /api/, /dashboard/, /checkout/ and /admin/ and gets the same low finding. The readiness snapshot also checks that robots.txt references a sitemap.
- Keep production robots.txt available at the root hostname.
- Keep the file under 500 KiB; Google ignores content beyond that.
- A robots.txt that returns a 5xx error can pause Google's crawling of the site; a 404 means no restrictions.
- Do not block CSS or JavaScript needed to render public pages.
- Review broad rules such as Disallow: / before every launch.
Build a sitemap from pages worth indexing
Include canonical, indexable URLs that return a successful response. Exclude dashboard screens, search results, temporary campaign variants, redirected URLs, and routes that carry private identifiers.
A URL marked noindex, or canonicalized to another page, should not be in the sitemap at all.
Set lastmod only when the page content changes significantly; Google uses it only when it is consistently accurate. One sitemap file is limited to 50,000 URLs or 50 MB uncompressed.
Discovery, crawling and indexing are different decisions
Googlebot discovers URLs through links and sitemaps, checks robots.txt before fetching pages, then can read canonical and noindex signals on allowed pages. A sitemap does not override robots.txt; blocking crawling can prevent a noindex directive from being seen.
Separate product and marketing surfaces
If the app and marketing site share one host, decide who owns what. The marketing build can generate the sitemap while product routes default to noindex where appropriate. If they use separate hosts, give each host its own crawl rules and only publish a sitemap for content that should be found.
- Homepage, pricing, feature pages, comparisons, and useful guides are typical sitemap entries.
- Login can stay crawlable but does not need to be in the sitemap. Google ignores the priority and changefreq fields, so leave them out rather than tuning them.
- Authenticated dashboards should not rely on robots.txt for privacy.
- Staging and preview hosts should require access control and stay outside public sitemaps.
Fix "Sitemap contains URLs which are blocked by robots.txt"
Search Console shows this in the Sitemaps report when a URL listed in your sitemap matches a Disallow rule in robots.txt. The sitemap asks for the page to be indexed while robots.txt tells crawlers not to fetch it, so decide which one is right for each URL.
If the page should rank, remove or narrow the Disallow rule that matches it (a broad rule such as Disallow: /app or a wildcard often catches public pages by accident). If the page should stay out of search, remove it from the sitemap instead; to keep it out of the index entirely, allow crawling and serve a noindex directive, because a blocked page cannot show its noindex.
While you are in robots.txt, add a Sitemap: line with the absolute URL of your sitemap, for example Sitemap: https://www.example.com/sitemap.xml. Search Console does not warn when this line is missing, but it helps other crawlers find the file. The URL can be on another host, though keeping it on your canonical host is simpler.
- Test each reported URL with URL Inspection in Search Console. Google applies the most specific (longest) matching rule and, when an Allow and a Disallow tie, the less restrictive one.
- Keep only canonical, indexable 200 URLs in the sitemap; drop redirects and noindex pages.
- Resubmit the sitemap in Search Console and validate the fix.
Fix "Blocked by robots.txt" and "Indexed, though blocked by robots.txt"
These two come from the Page indexing report, not the Sitemaps report. "Blocked by robots.txt" means Google did not crawl the URL because a rule matched. If the page should rank, narrow the rule.
"Indexed, though blocked by robots.txt" means Google indexed the URL from links without crawling it. If you want it out of search, remove the Disallow rule so Google can crawl the page and see a noindex directive. Leaving the block in place keeps the URL eligible to appear whenever other pages link to it.
Test the files after deployment
Fetch both files from the public domain, follow a sample of sitemap URLs, and check their status, canonical, and robots directives. Then submit the sitemap in Search Console and watch for excluded or redirected entries.
- In Next.js, generate both from app/robots.ts and app/sitemap.ts so the sitemap is built from the same route list as the site.
- Fetch them: curl -s https://www.example.com/robots.txt and curl -sI https://www.example.com/sitemap.xml (expect 200 and an XML content type).
- Run a free website scan: its readiness snapshot reports whether robots.txt, the sitemap and llms.txt are reachable.
Sources
Check your production site
See which of these issues are visible now.
ScanMySaaS checks the public surface and keeps the affected URL with every finding. Verify results before changing production.
Run a free scan