# @unom/vite-sitemap-plugin Vite plugin that writes `sitemap.xml` and `robots.txt` into your output directory at build start. Supports optional i18n routing with `hreflang` alternates. ## Install ```sh bun add -D @unom/vite-sitemap-plugin # or: npm i -D @unom/vite-sitemap-plugin ``` ## Usage ```ts // vite.config.ts import { defineConfig } from "vite"; import { sitemapPlugin } from "@unom/vite-sitemap-plugin"; export default defineConfig({ plugins: [ sitemapPlugin({ siteUrl: "https://example.com", routes: ["", "/about", { path: "/blog", changefreq: "weekly", priority: 0.8 }], robots: { disallow: ["/admin/"], }, }), ], }); ``` ### With locales (hreflang) ```ts sitemapPlugin({ siteUrl: "https://example.com", locales: ["en", "de", "es"], defaultLocale: "en", routes: ["", "/legal/imprint", "/legal/privacy"], }); ``` This emits one `` per `(locale, path)` pair with `` entries and an `x-default` pointing to `defaultLocale`. ## Options | Option | Type | Default | | --- | --- | --- | | `siteUrl` | `string` (required) | — | | `routes` | `Array` (required) | — | | `locales` | `string[]` | unset | | `defaultLocale` | `string` | first locale | | `formatUrl` | `(locale, path) => string` | `${siteUrl}/${locale}${path}` | | `lastmod` | `string \| Date` | build time | | `outDir` | `string` | `"public"` | | `sitemapFilename` | `string` | `"sitemap.xml"` | | `robotsFilename` | `string` | `"robots.txt"` | | `robots` | `RobotsOptions \| false` | `{}` | | `name` | `string` | `"vite-sitemap-plugin"` | `SitemapEntry` accepts `path`, `lastmod`, `changefreq`, `priority`. `RobotsOptions` accepts `disallow`, `allow`, `extraLines`, `userAgent`. ## License MIT