Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Core Nuxt module setup and comprehensive configuration options for sitemap generation, including single/multiple sitemap support, caching, filtering, and i18n integration.
The main Nuxt module definition that provides all sitemap functionality.
/**
* @nuxtjs/sitemap Nuxt module
* Main module function that integrates sitemap generation into Nuxt applications
*/
declare const _default: NuxtModule<ModuleOptions>;
export default _default;
export interface ModuleOptions extends SitemapDefinition {
enabled: boolean;
debug: boolean;
minify: boolean;
credits: boolean;
cacheMaxAgeSeconds: number | false;
autoLastmod: boolean;
discoverImages: boolean;
discoverVideos: boolean;
sortEntries: boolean;
excludeAppSources: true | AppSourceContext[];
sitemaps?: boolean | MultiSitemapsInput;
sitemapsPathPrefix: string | false;
appendSitemaps?: (string | SitemapIndexEntry)[];
xsl: string | false;
xslTips: boolean;
xslColumns?: XslColumn[];
defaultSitemapsChunkSize: number | false;
runtimeCacheStorage: boolean | (Record<string, any> & { driver: string });
autoI18n?: boolean | AutoI18nConfig;
strictNuxtContentPaths: boolean;
experimentalWarmUp?: boolean;
experimentalCompression?: boolean;
}Basic Setup Options
interface CoreOptions {
/** Whether the sitemap.xml should be generated (default: true) */
enabled: boolean;
/** Enables debug logs and a debug endpoint (default: false) */
debug: boolean;
/** Minify the sitemap XML (default: false) */
minify: boolean;
/** Should lastmod be automatically added to the sitemap (default: false) */
autoLastmod: boolean;
/** Should the sitemap.xml display credits for the module (default: true) */
credits: boolean;
/** How long, in seconds, should the sitemap be cached for (default: 600) */
cacheMaxAgeSeconds: number | false;
}Configuration for automatic content discovery during prerendering.
interface DiscoveryOptions {
/** When prerendering, should images be automatically discovered and added to the sitemap (default: true) */
discoverImages: boolean;
/** When prerendering, should videos be automatically discovered and added to the sitemap (default: true) */
discoverVideos: boolean;
/** Should the entries be sorted by loc (default: true) */
sortEntries: boolean;
/** Sources to exclude from the sitemap */
excludeAppSources: true | AppSourceContext[];
}
type AppSourceContext =
| 'nuxt:pages'
| 'nuxt:prerender'
| 'nuxt:route-rules'
| '@nuxtjs/i18n:pages'
| '@nuxt/content:document-driven';Support for generating multiple categorized sitemaps with sitemap index files.
interface MultiSitemapOptions {
/** Multiple sitemap support for large sites (default: false) */
sitemaps?: boolean | MultiSitemapsInput;
/** The path prefix for the sitemaps (default: '/__sitemap__/') */
sitemapsPathPrefix: string | false;
/** Sitemaps to append to the sitemap index (only works with multiple sitemaps) */
appendSitemaps?: (string | SitemapIndexEntry)[];
/** When chunking sitemaps into multiple files, how many entries per file (default: 1000) */
defaultSitemapsChunkSize: number | false;
}
type MultiSitemapsInput = Partial<MultiSitemapEntry> & Partial<IndexSitemapRemotes>;
interface MultiSitemapEntry {
[key: string]: Partial<SitemapDefinition>;
}
interface SitemapIndexEntry {
sitemap: string;
lastmod?: string;
_sitemapName?: string;
}Configuration for XML stylesheet and visual presentation of sitemaps.
interface StylingOptions {
/** Path to the XSL that styles sitemap.xml. Set to false to disable styling (default: '/__sitemap__/style.xsl') */
xsl: string | false;
/** Toggle the tips displayed in the XSL (default: true) */
xslTips: boolean;
/** Customize the columns displayed in the XSL */
xslColumns?: XslColumn[];
}
interface XslColumn {
label: string;
width: `${string}%`;
select?: string;
}Runtime cache configuration for performance optimization.
interface CacheOptions {
/**
* Modify the cache behavior.
* Boolean enables/disables runtime cache with default options.
* Record allows full configuration of runtime cache.
* (default: true)
*/
runtimeCacheStorage: boolean | (Record<string, any> & {
driver: string;
});
}Configuration for i18n integration and multi-language sitemap generation.
interface I18nOptions {
/** Automatically add alternative links to the sitemap based on a prefix list */
autoI18n?: boolean | AutoI18nConfig;
/** Enable when your nuxt/content files match your pages (default: false) */
strictNuxtContentPaths: boolean;
}
interface AutoI18nConfig {
differentDomains?: boolean;
locales: (LocaleObject & { _sitemap: string, _hreflang: string })[];
defaultLocale: string;
strategy: 'prefix' | 'prefix_except_default' | 'prefix_and_default' | 'no_prefix';
pages?: Record<string, Record<string, string | false>>;
}
interface LocaleObject extends Record<string, any> {
code: string;
name?: string;
dir?: 'ltr' | 'rtl' | 'auto';
domain?: string;
language?: string;
}Experimental features that may be enabled by default in future versions.
interface ExperimentalOptions {
/** Warm up the sitemap route(s) cache when Nitro starts */
experimentalWarmUp?: boolean;
/** Send the Sitemap as a compressed stream supporting gzip, brotli, etc. */
experimentalCompression?: boolean;
}Usage Examples:
// nuxt.config.ts - Basic configuration
export default defineNuxtConfig({
modules: ['@nuxtjs/sitemap'],
sitemap: {
hostname: 'https://example.com',
enabled: true,
debug: false,
minify: true,
cacheMaxAgeSeconds: 3600,
autoLastmod: true,
discoverImages: true,
urls: ['/custom-page']
}
})
// Multiple sitemaps configuration
export default defineNuxtConfig({
modules: ['@nuxtjs/sitemap'],
sitemap: {
hostname: 'https://example.com',
sitemaps: {
posts: {
includeAppSources: true,
include: ['/blog/**'],
defaults: { changefreq: 'weekly', priority: 0.7 }
},
pages: {
includeAppSources: true,
exclude: ['/blog/**'],
defaults: { changefreq: 'monthly', priority: 0.5 }
}
}
}
})
// i18n integration
export default defineNuxtConfig({
modules: ['@nuxtjs/sitemap', '@nuxtjs/i18n'],
sitemap: {
hostname: 'https://example.com',
autoI18n: true
}
})Install with Tessl CLI
npx tessl i tessl/npm-nuxtjs--sitemap