Generate the sitemap.xml file for a Astro app
Just copy and paste a file that will generate the sitemap.xml for the site, including all routes and their last modified dates.
Install @astrojs/sitemap
Section titled “Install @astrojs/sitemap”Install the dependency @astrojs/sitemap using npm, yarn or pnpm.
npm install @astrojs/sitemapyarn add @astrojs/sitemappnpm add @astrojs/sitemapAdd the file to your project
Section titled “Add the file to your project”Copy the astro.config.mjs file to your project’s root folder.
Edit the sitemapConfig object
Section titled “Edit the sitemapConfig object”Update the sitemapConfig object in the astro.config.mjs file with your site’s base URL and its manual routes.
const sitemapConfig: SitemapConfig = { baseUrl: "https://novajs.dev", manualRoutes: [ { route: "/react-hook-array", lastModified: "2025-06-14", }, { route: "/react-hook-async", lastModified: "2025-05-26", }, ],};