Generate deterministic sitemaps and robots.txt from code or data.
Define your site structure once using *.site-index.* modules, and generate identical artifacts across build tools, CLI workflows, and programmatic integrations.
The system is split into three focused packages:
site-index: core pipeline library (framework-agnostic)site-index-cli: CLI wrapper for Node/CI/cron usagevite-plugin-site-index: Vite integration built on top ofsite-index
All packages share the same module contract and produce the same output artifacts.
| Package | Purpose | Best for |
|---|---|---|
site-index |
Discovery, validation, and artifact generation | Programmatic integration in any Node app |
site-index-cli |
Run the pipeline from terminal/CI/cron | Scheduled jobs, static generation without custom glue code |
vite-plugin-site-index |
Vite build + dev integration | Vite apps that want sitemap + robots automatically |
Install based on your use case:
Vite app
npm install -D vite-plugin-site-indexCLI / CI / cron
npm install -D site-index-cliProgrammatic usage
npm install site-indexEach module must export a default array:
import type { SiteIndex } from "site-index";
export default [
{ url: "/" },
{ url: "/about" },
{ url: "/blog/first-post", sitemap: "blog" },
{ url: "/admin", index: false },
] satisfies SiteIndex[];Dynamic data is supported:
import type { SiteIndex } from "site-index";
const rows = [{ slug: "first-post", updatedAt: "2026-04-01T00:00:00.000Z" }];
export default rows.map((row) => ({
url: `/blog/${row.slug}`,
sitemap: "blog",
lastModified: row.updatedAt,
})) satisfies SiteIndex[];All packages produce the same artifact set:
sitemap.xml(index)sitemap-<name>.xmlrobots.txt
import { defineConfig } from "vite";
import { siteIndexPlugin } from "vite-plugin-site-index";
export default defineConfig({
plugins: [
siteIndexPlugin({
siteUrl: "https://example.com",
}),
],
});Behavior:
vite buildemits artifacts into the output bundlevite devserves up-to-date artifacts:/sitemap.xml/sitemap-<name>.xml/robots.txt
For CI, cron jobs, or manual builds.
npx site-index build --site-url https://example.com --root .import { runSiteIndexPipeline } from "site-index";
const result = await runSiteIndexPipeline({
siteUrl: "https://example.com",
discoveryRoot: process.cwd(),
loadDiscoveredModules: async (modules) => {
const data = await Promise.all(
modules.map(async (module) => ({
module,
exports: (await import(module.filePath)) as { default: unknown[] },
})),
);
return { data, warnings: [] };
},
});- Requires Node.js
- Uses file-based discovery via
*.site-index.*modules - Module loading relies on runtime execution (e.g. Vite SSR or native import)
This repository is an npm workspaces monorepo (packages/*).
npm install
npm run build
npm run typecheck
npm run lint
npm run testPer-package scripts are available under each packages/*/package.json.