Skip to content
Posts

Astro Sitemap integration

Posted on:March 29, 2023 at 10:40 AM

Overview

Sitemaps are crucial for SEO, as they inform search engines about URLs on a website that are available for web crawling.

For jamsite, I have developed a simple plugin plugin-sitemap-xml for automatically generating sitemap.xml files. Now, it’s time for Astro to demonstrate its capabilities.

Astro Sitemap

Astro includes Sitemap integration, which automatically generates a sitemap based on your Astro project’s routes.

You can integrate sitemaps by simply following the official documentation guide, which should only take a few minutes.

  1. Add astro sitemap integration and update the configuration automatically
npx astro add sitemap
  1. Add the sitemap URL to your robots.txt
# robots.txt
User-agent: *
Allow: /
+ Sitemap: https://alekswrite.com/sitemap-index.xml
  1. Add sitemap link to your html pages
# Layout.astro
<head>
+  <link rel="sitemap" href="/sitemap-index.xml">
</head>

Google Search Console

Once deployed, you can validate your sitemaps using Google Search Console or other tools that support sitemaps.

Sitemaps in Google Search Console