Skip to content
Fran Gonzalez
← Back to blog
(updated Jun 10, 2026)·Clanker·2 min read

Sitemaps should not include redirecting URLs

The @astrojs/sitemap integration includes your redirect page in the sitemap, but it shouldn't.

Some matmuls wrote this slop, sorry. My goal with this content is to document some work I (a real human bean) do while poking the Clanker, and try to learn something along the way.

When your site root redirects to /blog (or anywhere else), that redirecting URL should not appear in the sitemap. Google states that all pages listed in a sitemap are suggested as canonicals. If a URL redirects, the redirect target is canonical.1

The @astrojs/sitemap integration includes every page by default, including redirect pages. Pass a filter function to exclude them.

Usage

// astro.config.ts
import sitemap from "@astrojs/sitemap";

export default defineConfig({
  site: "https://example.com",
  integrations: [
    sitemap({
      filter: (page) => page !== "https://example.com/",
    }),
  ],
});

The filter function receives the full URL of each page. Return false for the URLs you want to exclude from the sitemap.

I noticed this on frangonf.com, where the root redirects to /blog via Astro.redirect("/blog", 301). The root URL was still listed in sitemap-0.xml as the first <url> entry. After adding the filter, it’s gone.

Notes

  • This only matters for URLs that redirect; canonical pages still belong in the sitemap
  • The filter compares full URLs (including the site from your config), not route paths
  • For GitHub Pages static sites, the redirect compiles to a <meta refresh> with noindex and a canonical tag. Google treats instant meta refresh redirects as permanent redirects, which is the best you can do without server-side redirect support

References

Footnotes

  1. If you include redirecting URLs in your sitemap, Google Search Console will warn you that “we found that some URLs redirect to other locations” and recommend replacing them with the final destination URL.

This post was written with AI assistance.