or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

content-integration.mddata-types-configuration.mdindex.mdmodule-configuration.mdserver-composables.mdxml-html-utilities.md
tile.json

tessl/npm-nuxtjs--sitemap

Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@nuxtjs/sitemap@7.4.x

To install, run

npx @tessl/cli install tessl/npm-nuxtjs--sitemap@7.4.0

index.mddocs/

@nuxtjs/sitemap

@nuxtjs/sitemap is a comprehensive Nuxt.js module that provides powerfully flexible XML sitemap generation capabilities for Nuxt applications. It offers single and multiple sitemap support, automatic URL discovery, image and video discovery, lastmod detection, SWR caching, i18n integration, and extensive customization options for SEO-compliant XML sitemaps.

Package Information

  • Package Name: @nuxtjs/sitemap
  • Package Type: npm
  • Language: TypeScript
  • Installation: npx nuxi@latest module add sitemap

Core Imports

// Main module and types
import type { ModuleOptions } from '@nuxtjs/sitemap';

// Content integration
import { schema, asSitemapCollection } from '@nuxtjs/sitemap/content';

// Utilities
import { parseSitemapXml, parseHtmlExtractSitemapMeta } from '@nuxtjs/sitemap/utils';

Server-only imports (available only in server context):

// Server composables (only available in Nuxt server context)
import { asSitemapUrl, defineSitemapEventHandler } from '#sitemap/server/composables';

Basic Usage

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxtjs/sitemap'],
  sitemap: {
    hostname: 'https://example.com',
    gzip: true,
    urls: [
      '/special-page',
      {
        loc: '/priority-page',
        lastmod: new Date(),
        changefreq: 'weekly',
        priority: 0.8
      }
    ]
  }
})

Architecture

@nuxtjs/sitemap is built around several key components:

  • Module System: Core Nuxt module providing automatic route discovery and sitemap generation
  • Configuration Engine: Comprehensive options system for sitemap behavior, chunking, and filtering
  • Multi-sitemap Support: Ability to generate multiple categorized sitemaps with index files
  • Content Integration: Deep integration with Nuxt Content for automatic content-driven sitemaps
  • Server Runtime: Server-side composables and utilities for dynamic sitemap generation
  • Type System: Complete TypeScript type definitions for all APIs and configuration options
  • Parsing Utilities: Tools for parsing existing XML sitemaps and extracting metadata from HTML

Capabilities

Module Configuration

Core Nuxt module setup and comprehensive configuration options for sitemap generation, including single/multiple sitemap support, caching, filtering, and i18n integration.

interface ModuleOptions extends SitemapDefinition {
  enabled: boolean;
  debug: boolean;
  minify: boolean;
  credits: boolean;
  autoLastmod: boolean;
  excludeAppSources: true | AppSourceContext[];
  sortEntries: boolean;
  discoverImages: boolean;
  discoverVideos: boolean;
  defaultSitemapsChunkSize: number | false;
  sitemaps?: boolean | MultiSitemapsInput;
  sitemapsPathPrefix: string | false;
  appendSitemaps?: (string | SitemapIndexEntry)[];
  xsl: string | false;
  xslTips: boolean;
  xslColumns?: XslColumn[];
  cacheMaxAgeSeconds: number | false;
  runtimeCacheStorage: boolean | (Record<string, any> & { driver: string });
  autoI18n?: boolean | AutoI18nConfig;
  strictNuxtContentPaths: boolean;
  experimentalWarmUp?: boolean;
  experimentalCompression?: boolean;
}

Module Configuration

Content Integration

Nuxt Content integration with sitemap-specific schema validation and collection enhancement for seamless content-driven sitemap generation.

function asSitemapCollection<T extends ZodRawShape>(
  collection: Collection<T>
): Collection<T>;

const schema: ZodObject<{
  sitemap: ZodObject<SitemapContentFields>
}>;

Content Integration

Server Composables

Server-side composables and utilities for runtime sitemap generation, URL processing, and event handler creation within the Nuxt server context.

function asSitemapUrl(
  url: SitemapUrlInput | Record<string, any>
): SitemapUrlInput;

const defineSitemapEventHandler: typeof defineEventHandler<
  EventHandlerRequest, 
  EventHandlerResponse<SitemapUrlInput[]>
>;

Server Composables

XML and HTML Utilities

Utility functions for parsing existing XML sitemaps and extracting sitemap metadata from HTML documents for analysis and integration purposes.

function parseSitemapXml(xml: string): Promise<SitemapParseResult>;

function parseHtmlExtractSitemapMeta(
  html: string, 
  options?: {
    images?: boolean;
    videos?: boolean;
    lastmod?: boolean;
    alternatives?: boolean;
    resolveUrl?: (s: string) => string;
  }
): SitemapUrl[];

interface SitemapParseResult {
  urls: SitemapUrlInput[];
  warnings: SitemapWarning[];
}

interface SitemapWarning {
  type: 'validation';
  message: string;
  context?: {
    url?: string;
    field?: string;
    value?: unknown;
  };
}

XML and HTML Utilities

Data Types and Configuration

Comprehensive type system covering sitemap entries, validation schemas, configuration interfaces, and runtime context objects for full type safety.

interface SitemapUrl {
  loc: string;
  lastmod?: string | Date;
  changefreq?: Changefreq;
  priority?: 0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1;
  alternatives?: AlternativeEntry[];
  images?: ImageEntry[];
  videos?: VideoEntry[];
}

interface SitemapDefinition {
  include?: FilterInput[];
  exclude?: FilterInput[];
  sitemapName: string;
  urls?: MaybeFunction<MaybePromise<SitemapUrlInput[]>>;
  sources?: SitemapSourceInput[];
}

Data Types and Configuration