Skip to content

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 the dependency @astrojs/sitemap using npm, yarn or pnpm.

Terminal window
npm install @astrojs/sitemap

Copy the astro.config.mjs file to your project’s root folder.

Update the sitemapConfig object in the astro.config.mjs file with your site’s base URL and its manual routes.

astro.config.mjs
const sitemapConfig: SitemapConfig = {
baseUrl: "https://novajs.dev",
manualRoutes: [
{
route: "/react-hook-array",
lastModified: "2025-06-14",
},
{
route: "/react-hook-async",
lastModified: "2025-05-26",
},
],
};