2026-05-12 19:44:00 +02:00
2026-05-12 19:44:00 +02:00
2026-05-12 19:44:00 +02:00
2026-05-12 19:44:00 +02:00
2026-05-12 19:44:00 +02:00
2026-05-12 19:44:00 +02:00
2026-05-12 19:44:00 +02:00
2026-05-12 19:44:00 +02:00

@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

bun add -D @unom/vite-sitemap-plugin
# or: npm i -D @unom/vite-sitemap-plugin

Usage

// 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)

sitemapPlugin({
  siteUrl: "https://example.com",
  locales: ["en", "de", "es"],
  defaultLocale: "en",
  routes: ["", "/legal/imprint", "/legal/privacy"],
});

This emits one <url> per (locale, path) pair with <xhtml:link rel="alternate" hreflang="…"> entries and an x-default pointing to defaultLocale.

Options

Option Type Default
siteUrl string (required)
routes Array<string | SitemapEntry> (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

S
Description
No description provided
Readme 41 KiB
Languages
TypeScript 100%