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.
- Add astro sitemap integration and update the configuration automatically
npx astro add sitemap
- Add the sitemap URL to your robots.txt
# robots.txt
User-agent: *
Allow: /
+ Sitemap: https://alekswrite.com/sitemap-index.xml
- 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.