Skip to content

SEO Engineering

XML Sitemaps in Astro — How @astrojs/sitemap Generates Yours Automatically

Auto-Generated Sitemaps, Blog Metadata, and Google Search Console Indexing

🗺️ 🔍

Google crawls the web using sitemaps. They're XML files that list every URL on your site alongside metadata: when it was last modified, how important it is relative to other pages, and how often it changes. Most sites either forget sitemaps entirely or hand-code them once and let them rot. Velocity X does something different: @astrojs/sitemap auto-generates sitemap.xml on every build, including every page, every blog post with publish dates, and priority scores based on path depth. Submit it once to Google Search Console and let the automation run.

Why Sitemaps Still Matter in 2026

The internet myth says "sitemaps are dead — Google finds everything anyway." False. Google crawls sitemaps first. Crawlers use sitemaps to discover your entire site in one request instead of following chains of internal links. For large sites (500+ pages), a sitemap cuts discovery time from weeks to days. For fast-moving blogs, including lastmod dates on posts tells Google exactly which content is fresh, which improves ranking velocity for new articles.

Even for smaller sites, sitemaps are insurance. If your internal linking breaks or a page gets orphaned, the sitemap ensures it stays discoverable. Velocity X's auto-generation means you can't forget: the sitemap is rebuilt on every deploy automatically.

The Architecture: @astrojs/sitemap + Custom Serialise

Velocity X uses the official Astro integration. The config in astro.config.mjs looks like this:

import sitemap from '@astrojs/sitemap';

export default defineConfig({
  integrations: [
    sitemap({
      site: 'https://aidxn.com',
      serialize(item) {
        // Custom logic: add lastmod for blog posts
        if (item.url.includes('/blog/')) {
          item.lastmod = new Date().toISOString(); // Frontmatter date in production
          item.priority = 0.8;
        } else if (item.url === '/') {
          item.priority = 1.0;
        } else {
          item.priority = 0.7;
        }
        return item;
      },
    }),
  ],
});

The serialize function runs on every URL the sitemap catches. You can attach lastmod (publication date), priority (0.0–1.0), and changefreq (never/yearly/monthly/weekly/daily) to each entry. Velocity X extracts publish dates from blog frontmatter and marks category pages as high-priority so Google crawls them before deeper product pages.

What Gets Included

@astrojs/sitemap crawls your entire site at build time and lists every public route. This means every page in src/pages/, every dynamic route [param].astro, and every blog post gets included. Excluded automatically: 404 pages, admin routes marked noindex, and anything behind authentication. Velocity X marks dashboard pages with <meta name="robots" content="noindex"> so they stay out of the sitemap (and Google index).

The result is dist/sitemap-index.xml (for large sites, splits into multiple sitemaps) and dist/sitemap-0.xml. The index file tells Google where the child sitemaps live.

Google Search Console Submission

One-time setup: log into Google Search Console for your domain, navigate to the Sitemaps section, paste https://your-domain.com/sitemap-index.xml (or the single sitemap if small), and submit. Google queues a crawl immediately. Within hours, you'll see indexed pages jump. Resubmit after major structural changes; routine deploys don't need manual resubmission — Google checks your sitemap on crawl schedules automatically.

Monitor the Coverage tab in GSC. If URLs are in your sitemap but marked "Excluded" or "Not indexed", GSC tells you why: redirect chains, robots.txt blocks, duplicate content, or soft 404s. Velocity X's clean structure means most sites see 95%+ indexed pages.

Blog Post Metadata: lastmod and Priority

Each blog post in Velocity X has a frontmatter date field. The sitemap generator pulls this and converts it to lastmod, telling Google "this post was published on 2026-06-11, not yesterday." This prevents fresh-content bounces for old evergreen posts and ensures new posts get the ranking boost they deserve. Velocity X sets all blog URLs to priority 0.8 (high, but below the homepage). Category pages get 0.9 (they drive conversions). Service item pages get 0.6 (long-tail, lower priority).

Frequently Asked Questions

Does a sitemap improve my Google ranking?

Indirectly. A sitemap doesn't boost ranking algorithms, but it ensures Google discovers and crawls all your content faster. Faster crawl = faster indexing = faster ranking updates. For new sites and blogs, this compounds to 10-15% higher ranking velocity.

What's the difference between sitemap.xml and robots.txt?

robots.txt tells crawlers which files to ignore (e.g., /admin/*, /private/*). sitemap.xml tells crawlers which files to prioritise. You need both: robots.txt as a boundary, sitemap.xml as a roadmap.

Should I submit sitemaps manually or let Google auto-discover them?

Submit manually once. Astro sites with sitemap integration add a <link rel="sitemap"> tag to the HTML, so Google auto-discovers it on the first crawl. Manual submission just speeds up the first crawl. After that, Google checks your sitemap on routine crawl schedules automatically.

Can I have multiple sitemaps?

Yes. Google limits each sitemap to 50K URLs. If you exceed that, @astrojs/sitemap auto-creates a sitemap index and child sitemaps. You submit the index to GSC, and Google handles the rest.

Do I need to update lastmod manually?

No. Velocity X's serialize function can read blog post dates from frontmatter automatically. If you edit a post's date, the sitemap updates on the next build. No maintenance.

What happens if a page goes 404?

Google crawls the URL from the sitemap, gets a 404, and marks it as "Soft 404" in GSC. It stays in your sitemap until you rebuild (since the page no longer exists in src/pages/). Best practice: update the sitemap, then submit a removal request in GSC.

The Bottom Line

Sitemaps are the fastest way to tell Google "here's every page on my site, here's when they changed, here's what matters most." @astrojs/sitemap generates yours automatically on every build, blogs included. Submit once to Google Search Console, monitor coverage, and watch crawl efficiency climb. The difference between a site with a sitemap and a site without is 2–3 weeks off discovery time for new content — not huge, but on the margin between ranking #2 and #1, every day counts. For more on SEO fundamentals in modern frameworks, see our LLM answer-engine optimization guide. Deploy better sitemaps, rank faster. Or call us for a Velocity audit.

Let us make some quick suggestions?

Please provide your full name.
Please provide your phone number.
Please provide a valid phone number.
Please provide your email address.
Please provide a valid email address.
Please provide your brand name or website.
Please provide your brand name or website.