# Generate the sitemap.xml file for a site

`seo-in-astro` can generate the `sitemap.xml` file for your Astro site with automatic route detection.

## Enabling sitemap.xml generation

The sitemap is generated by default without any configuration needed. `seo-in-astro` automatically detects and includes all routes in your Astro site in the generated `sitemap.xml` file.

## Viewing the `sitemap.xml` file

1. Run a build for your Astro project.

   ```sh
   npm run build
   ```

   ```sh
   yarn build
   ```

   ```sh
   pnpm build
   ```

2. Start the preview server.

   ```sh
   npm run preview
   ```

   ```sh
   yarn preview
   ```

   ```sh
   pnpm preview
   ```

3. Open http://localhost:4321/sitemap-0.xml in your browser to see the generated file.

## Advanced sitemap configuration

By default, `seo-in-astro` generates a basic sitemap with all detected routes.

However, you can customize each route's metadata by using the `sitemapXml` option in the integration configuration.

This option allows you to specify additional properties for each route, such as modification date, priority, change frequency, and more.

```js
// astro.config.mjs
import { defineConfig } from "astro/config";
import { seoInAstro } from "seo-in-astro";

export default defineConfig({
  integrations: [
    seoInAstro({
      baseUrl: "https://example.com",
      siteName: "Example",
      defaultOgImg: "/default-og.png",
      sitemapXml: {
        sitemap: [
          {
            route: "/",
            lastModified: new Date(),
            changeFrequency: "daily",
            priority: 1,
          },
          {
            route: "/about",
            lastModified: new Date("2024-01-15"),
            changeFrequency: "monthly",
            priority: 0.8,
          },
        ],
      },
    }),
  ],
});
```