Skip to content

Sitemap Plugin

A staticbolt plugin that generates a sitemap.xml file at build time by scanning the HTML files in your output directory. It writes the file only during production builds, and only when sitemapUrl is set.

Installation

The plugin ships as part of @staticbolt/core. You do not need to install anything else.

Usage

In your .staticbolt.ts configuration file:

import { defineConfig } from "@staticbolt/core";
import { sitemapPlugin } from "@staticbolt/core/plugins";
export default defineConfig({
plugins: [
sitemapPlugin({
sitemapUrl: "https://example.com",
}),
],
});

Every HTML file found in the output directory becomes a <loc> entry in the sitemap, with its path resolved against sitemapUrl.

Plugin Options

sitemapUrl

  • Type: string

The base URL of your site. Every page URL in the sitemap is resolved from this value. The plugin does nothing if you leave this option unset.

include

  • Type: string[]
  • Default: ["**/*.html"]

Glob patterns for HTML files to include in the sitemap. Patterns are matched relative to the output directory.

exclude

  • Type: string[]
  • Default: []

Glob patterns for HTML files to exclude from the sitemap. Patterns are matched relative to the output directory.

sitemapPlugin({
sitemapUrl: "https://example.com",
exclude: ["404.html", "admin/**/*.html"],
});

outfile

  • Type: string
  • Default: "sitemap.xml"

The output path for the generated sitemap, relative to the build output directory.