Check 03.08 · Crawling

Exclude redirects, errors and noindex pages

Find and remove redirected, erroring or noindex URLs from your sitemaps on WordPress, Shopify, Next.js, Laravel, Webflow or Wix, then automate the check.

Priority
Critical
Difficulty
Intermediate
Estimated time
1 to 3 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

An XML sitemap lists the pages you want to see in search results. URLs that redirect (3xx status codes), return an error (4xx, 5xx, soft 404) or carry a noindex directive do not belong there: they tell search engines “index this” while the page says the opposite. Once the check is done, every URL in your sitemaps returns 200, with no noindex, and the generator automatically drops pages whose status changes.

Why it matters

Google puts it simply: a sitemap contains the URLs you want to appear in search results. When Search Console reads a sitemap successfully, all its URLs are queued for crawling. Every dead or excluded URL therefore uses up a request for nothing, and sends a contradictory signal:

  • A redirect listed in the sitemap suggests that the source URL is the right version, whereas the redirect points to the destination. The sitemap is one of the canonicalization signals: you muddle the choice of the selected URL.
  • A 404 or 410 error signals a page that no longer exists; it is retried every time the sitemap is reread.
  • A noindex directly contradicts the sitemap. The search engine obeys the page, but you have spent a crawl to learn that.

The most concrete cost lies elsewhere: your reports become unreadable. The “All submitted pages” filter in the Search Console indexing report is used to measure the share of your useful pages that are actually indexed. If it mixes redirected, deleted and deliberately excluded pages, that rate no longer means anything and real problems get lost in the noise.

On the generative engine side, Bing presents its sitemaps as a way to surface up-to-date content quickly, including in its AI-generated answers. A sitemap cluttered with dead URLs weakens this signal, though the effect cannot be measured.

What it improves

  • Crawling Crawler requests go to useful pages. Noticeable mostly on sites with tens of thousands of URLs.
  • Diagnostics The indexing rate of submitted pages becomes a reliable indicator again, the basis for monitoring indexing reports (opens in a new tab).
  • Canonicalization Sitemap, canonical tag and redirects all say the same thing.
  • Freshness A clean sitemap helps Google and Bing spot what changes quickly. Indirect effect.
  • Rankings No direct effect. A URL returning an error in a sitemap does not penalize the site.

How to check

In Search Console. Open the Sitemaps report, click a sitemap, then the link to its page indexing. You can also open the Page indexing report and choose “All submitted pages” in the menu at the top left. Under “Why pages aren't indexed”, the reasons that point to a dirty sitemap are: Page with redirect, Not found (404), Excluded by ‘noindex’ tag, Soft 404, Server error (5xx), Blocked by robots.txt, Duplicate, Google chose different canonical than user. Click a reason to get example URLs.

In Bing Webmaster Tools. The Sitemaps page shows the status of each file and the number of URLs discovered; check a few suspicious URLs with URL Inspection.

With a script, across the whole sitemap. This dependency-free Python script reads a sitemap or an index (even compressed as .gz), requests each URL without following redirects and keeps only the failing lines:

# audit_sitemap.py — usage: python3 audit_sitemap.py https://example.com/sitemap.xml > defauts.csv
import csv, gzip, re, sys, urllib.error, urllib.request
import xml.etree.ElementTree as ET

NS = {"sm": "http://www.sitemaps.org/schemas/sitemap/0.9"}
UA = "Mozilla/5.0 (compatible; audit-sitemap/1.0)"

class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, *args, **kwargs):
        return None

opener = urllib.request.build_opener(NoRedirect)

def fetch(url):
    request = urllib.request.Request(url, headers={"User-Agent": UA})
    try:
        response = opener.open(request, timeout=20)
        return response.status, response.headers, response.read()
    except urllib.error.HTTPError as error:
        return error.code, error.headers, b""

def sitemap_urls(url):
    status, headers, body = fetch(url)
    if status != 200:
        print(f"Unreadable sitemap ({status}): {url}", file=sys.stderr)
        return
    if body[:2] == b"\x1f\x8b":
        body = gzip.decompress(body)
    root = ET.fromstring(body)
    if root.tag.endswith("sitemapindex"):
        for loc in root.findall("sm:sitemap/sm:loc", NS):
            yield from sitemap_urls(loc.text.strip())
        return
    for loc in root.findall("sm:url/sm:loc", NS):
        yield loc.text.strip()

def audit(url):
    status, headers, body = fetch(url)
    problems = []
    if status != 200:
        problems.append(f"HTTP {status}")
    if status in (301, 302, 303, 307, 308):
        problems.append(f"to {headers.get('Location', '?')}")
    if "noindex" in (headers.get("X-Robots-Tag") or "").lower():
        problems.append("X-Robots-Tag noindex")
    html = body[:500000].decode("utf-8", "ignore")
    for tag in re.findall(r"<meta[^>]+>", html, re.I):
        if re.search(r"name=[\"'](robots|googlebot|bingbot)[\"']", tag, re.I) and "noindex" in tag.lower():
            problems.append("meta noindex")
    match = re.search(r"<link[^>]+rel=[\"']canonical[\"'][^>]*>", html, re.I)
    if match:
        href = re.search(r"href=[\"']([^\"']+)", match.group(0))
        if href and href.group(1) != url:
            problems.append(f"canonical to {href.group(1)}")
    return status, problems

writer = csv.writer(sys.stdout)
writer.writerow(["url", "code", "problems"])
for page in sitemap_urls(sys.argv[1]):
    code, problems = audit(page)
    if problems:
        writer.writerow([page, code, "; ".join(problems)])

Expected result: a file that contains only the header line. The script does not detect soft 404s (empty pages served with 200): Search Console remains the reference for that case. On a large site, run it outside peak hours, as it sends one request per URL.

With Screaming Frog. Tick Configuration > Spider > Crawl > Crawl Linked XML Sitemaps, enter the sitemap URL, run the crawl and then Crawl Analysis > Start. In the Sitemaps tab, the “Non-Indexable URLs in Sitemap” filter lists URLs that are redirected, erroring, noindex or canonicalized elsewhere, with the reason in the “Indexability Status” column. The free version is limited to 500 URLs.

How to implement

Before you start

Apply the same rule everywhere:

URL response In the sitemap? Action
200, indexable, canonical pointing to itself Yes Nothing
301 or 308 (permanent move) No List the destination URL
302 or 307 (temporary) No, while the redirect lasts Add it back when the operation ends
404 or 410 No Remove, and fix internal links (opens in a new tab)
Recurring 5xx No, while the error lasts Fix the server error (opens in a new tab)
503 for scheduled maintenance Yes Remove nothing for a few hours
Soft 404 (empty category, product page with no content) No Remove, or add content back
noindex in a meta tag or an X-Robots-Tag header No Remove; if the noindex is a mistake, see remove accidental noindex tags (opens in a new tab)
Blocked by robots.txt No The search engine cannot read the page
Canonical pointing to another URL No List the canonical (see include only indexable canonical URLs (opens in a new tab))
Protected access (401, 403) No Private page, outside the sitemap

The principle that prevents regressions: the sitemap must be produced from the state of the content (published, indexable, canonical, not redirected), with the same rule as the one that writes the page's robots tag. A static sitemap, generated once and then forgotten, always ends up listing dead pages: switch to automatic generation (opens in a new tab).

Good to know: during a migration with URL changes, Google advises the opposite: temporarily submit a sitemap of the old URLs, so that it discovers the redirects quickly. Search Console will show warnings about these redirects: they are expected. Remove this sitemap once the new URLs have been picked up.

WordPress

Versions WordPress 5.5 to 7.1; Yoast SEO 20 to 28; Rank Math 1.0.

Yoast SEO. A post set to “No” for the question “Allow search engines to show this content in search results?” (Advanced tab of the Yoast box) automatically leaves the sitemap. A content type or taxonomy hidden from search results in Yoast SEO > Settings > Content types disappears from the sitemap entirely. The index is at /sitemap_index.xml.

Rank Math. Same logic: a noindex post is removed. In Rank Math SEO > Sitemap Settings, turn off “Include in Sitemap” for content types and taxonomies with no value, and use the exclusion-by-ID field for isolated cases.

Without an SEO plugin, the native sitemap (/wp-sitemap.xml) knows nothing about your noindex settings. Add this to a custom plugin or to the child theme's functions.php:

// Removes posts flagged with a _exclure_sitemap custom field
add_filter('wp_sitemaps_posts_query_args', function (array $args, string $postType): array {
    $args['meta_query'] = [
        [
            'key' => '_exclure_sitemap',
            'compare' => 'NOT EXISTS',
        ],
    ];

    return $args;
}, 10, 2);

// Removes the authors sitemap, often redirected or of no value
add_filter('wp_sitemaps_add_provider', function ($provider, string $name) {
    return $name === 'users' ? false : $provider;
}, 10, 2);

A common trap: a page redirected by a redirection plugin but left “published” stays in the sitemap. Move it to draft or to the trash once the redirect is in place. Then purge the caching plugin's cache and the CDN, which may keep an old version of the sitemap.

Shopify

Versions Shopify, all plans, November 2026.

The sitemap is generated and updated automatically; it cannot be edited. Shopify only applies a URL redirect (the URL redirects section, in the store's navigation) if no resource exists at the old address any more, which limits redirects in the sitemap.

To remove a specific resource, Shopify documents the seo.hidden metafield (namespace seo, key hidden, integer type, value 1): it adds noindex and nofollow to the page and removes it from the sitemap. Create the definition in Settings > Metafields and metaobjects, then fill it in on the relevant resource or through the Admin API. The page also no longer appears in the store's internal search: reserve it for pages that have no business in search results.

Next.js

Versions Next.js 15 and 16 (App Router).

The app/sitemap.ts file returns whatever you give it: filter at the source.

import type { MetadataRoute } from 'next'
import { getPages } from '@/lib/cms'

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
  const pages = await getPages()

  return pages
    .filter((page) => page.status === 'published')
    .filter((page) => !page.noindex)
    .filter((page) => !page.redirectTo)
    .filter((page) => !page.canonicalUrl || page.canonicalUrl === page.url)
    .map((page) => ({
      url: page.url,
      lastModified: page.contentUpdatedAt,
    }))
}

Redirects declared in next.config.ts or next.config.js (the redirects() function) or in proxy.ts (called middleware.ts before Next.js 16) are unknown to the sitemap: make sure no redirect source appears in it, for example by running the script from the “How to check” section after each staging deployment.

Laravel

Versions Laravel 11 to 13; spatie/laravel-sitemap 7.3 and 8.x.

With the spatie/laravel-sitemap package, build the sitemap from the models rather than by crawling the site, with an Eloquent scope that reflects your indexing rules:

namespace App\Console\Commands;

use App\Models\Post;
use Illuminate\Console\Command;
use Spatie\Sitemap\Sitemap;

class GenerateSitemapCommand extends Command
{
    protected $signature = 'generate-sitemap';

    protected $description = 'Generate the XML sitemap from indexable content';

    public function handle(): void
    {
        $posts = Post::query()
            ->where('status', 'published')
            ->where('noindex', false)
            ->whereNull('redirect_to')
            ->get();

        $this->info("Adding {$posts->count()} posts...");

        Sitemap::create()
            ->add($posts)
            ->writeToFile(public_path('sitemap.xml'));

        $this->comment('Sitemap written.');
    }
}

The Post model implements Spatie\Sitemap\Contracts\Sitemapable (toSitemapTag() method). Schedule the command in routes/console.php with Schedule::command('generate-sitemap')->daily();. If you use crawl mode (SitemapGenerator), the hasCrawled() callback lets you drop a URL by not returning it.

Webflow

Versions Webflow, all site plans, November 2026.

In the page settings, SEO section, turn off “Sitemap indexing”: Webflow adds a noindex tag and removes the page from the sitemap. CMS collection items have their own toggle in their settings. This setting only exists if the automatic sitemap is turned on (Site settings > SEO > Sitemap). A noindex added through custom code, on the other hand, leaves the page in the sitemap.

Wix

Versions Wix editor and Wix Studio, all plans, November 2026.

In the page's SEO settings, turn off “Let search engines index this page”: Wix adds noindex. The sitemap cannot be edited by hand and Wix only says that these pages may no longer appear in it: open /sitemap.xml after the change to confirm.

Automated check

Once the sitemap is clean, keep it from getting dirty again: run the check script after every deployment and every month, and make the release fail if the defects file contains more than the header. See Monitor canonicals and sitemaps (opens in a new tab).

Common mistakes

  • Listing URLs with http:// or without www while the site redirects to https://www.: every URL in the sitemap becomes a redirect.
  • Forgetting the trailing slash: /guide in the sitemap, /guide/ on the site, and every URL returns 301.
  • Adding a noindex in the theme code without the sitemap generator knowing about it: the two sources drift apart.
  • Thinking that removing a page from the sitemap deindexes it: it does not. To take a page out of the index, you need a noindex, a 404 or 410 error, or a redirect. Google even states that deleting a sitemap in Search Console does not make it forget its URLs.
  • Removing deleted products from the sitemap but not from internal links: internal links keep sending crawlers to 404 pages.
  • Removing URLs during a maintenance window of a few hours: a temporary 503 is no reason to empty the sitemap.
  • Filing “Crawled - currently not indexed” among technical errors: this reason relates to quality or demand, not to the sitemap.

Frequently asked questions

Should noindex pages be removed from the sitemap?

Yes, a noindex page has no business in a sitemap. The sitemap tells search engines “here are the pages to index” and the noindex tag says the opposite: the search engine follows the page, but you waste a crawl and distort the indexing rate of submitted pages in Search Console. Configure the generator to automatically exclude any page that is switched to noindex.

Does a redirecting URL in the sitemap penalize the site?

No, a redirected URL in a sitemap does not cause a penalty. It costs the crawler a useless request and slightly muddles the choice of canonical URL, since the sitemap points to the source while the redirect points to the destination. The real damage is cluttered Search Console reports. Replace the redirected URL with its final destination, which must return 200.

Is removing a page from the sitemap enough to deindex it?

No, removing a page from the sitemap does not take it out of the index. Google and Bing also know the page through links and their past crawls. To deindex it, the page must carry a noindex directive, return 404 or 410, or redirect to another URL. Google also states that deleting a sitemap in Search Console does not make it forget the URLs it contained.

Should old URLs stay in the sitemap during a migration?

Yes, temporarily. During a migration with URL changes, Google recommends submitting both the sitemap of the new URLs and that of the old ones, which redirect, to speed up discovery of the redirects. Search Console warnings about these redirects are then normal. When the number of old URLs still indexed falls close to zero, remove this transitional sitemap and keep only the new one.

Updated on

Topic checklist (PDF)

And now?

In the “Crawling” topic

  1. Check robots.txt access and syntax
  2. Allow Googlebot on strategic pages
  3. Allow Bingbot on strategic pages
  4. Allow required CSS/JS resources
  5. Declare sitemaps in robots.txt
  6. Generate the XML sitemap automatically
  7. Include only indexable canonical URLs returning HTTP 200
  8. Exclude redirects, errors and noindex pages
  9. Provide a reliable lastmod
  10. Split large sitemaps
  11. Stay within 50,000 URLs and 50 MB uncompressed per sitemap
  12. Submit sitemaps to Google and Bing
  13. Analyze crawl stats
  14. Analyze server logs
  15. Identify crawler traps
  16. Optimize crawl budget if warranted
  17. Check CDN, WAF and anti-bot protection
  18. Check that public pages are accessible without authentication
  19. Monitor DNS and server errors
  20. Set up IndexNow if relevant