Sitemap Plugin
Purpose
Generates a sitemap.xml file containing URLs for all published content, optional paginated listing URLs, and optional collection URLs. Supports URL deduplication and lastmod tracking.
Location
- Package:
@shevky/plugin-sitemap - Main:
plugin-sitemap/main.js(~363 lines) - Runtime name:
shevky-sitemap
Lifecycle Hooks
| Hook | Implemented |
|---|---|
content:ready | ✓ |
How It Works
During content:ready:
- Collects content entries from
ctx.contentFiles- one<url>per published page. - If
config.seo.includePagingis enabled, generates additional URLs for paginated listing pages (e.g.,page-2,page-3). - If
config.seo.includeCollectionsis enabled, generates URLs for collection pages (tags, categories, series) usingcontent.collectionsconfig definitions. - Merges and deduplicates all entries by URL, keeping the most recent
lastmod. - Sorts by lastmod descending.
- Renders and writes
dist/sitemap.xml.
Configuration
Plugin-specific config from pluginConfigs["shevky-sitemap"]:
| Key | Type | Default | Description |
|---|---|---|---|
sitemapFilename | string | "sitemap.xml" | Output filename |
Global config keys that affect sitemap generation:
| Key | Effect |
|---|---|
seo.includeCollections | Include collection page URLs |
seo.includePaging | Include pagination URLs |
content.pagination.pageSize | Items per page for pagination URL counting |
content.pagination.segment | Localized pagination URL segment (e.g., "page", "sayfa") |
content.collections | Collection definitions with types and slugPattern |
Collection URL Generation
Collections are defined in content.collections:
"collections": {
"tags": {
"types": ["tag"],
"slugPattern": { "en": "tag/", "tr": "etiket/" }
}
}The plugin iterates ctx.pages (collection data), matches collection types, and generates URLs using the slug pattern.
Dependencies
@shevky/base-i18n,plugin,format
Risks and Limitations
- Duplicated URL logic: Reimplements
buildContentUrl()internally rather than using the core MetaEngine. URL logic changes in core may not be reflected. - Single sitemap: Does not generate a sitemap index for very large sites (>50,000 URLs).
- Collection config shape: Depends on a specific
content.collectionsstructure withtypesandslugPattern.
Related
- RSS Plugin - similar content:ready pattern
- Robots Txt Plugin - references the sitemap