sitemap-rs
A Rust library to generate URL, index, image, video, and news XML sitemaps.
Repository Health
Technical Analysis
sitemap-rs is a Rust library for generating every flavor of XML sitemap: standard URL sitemaps, sitemap index files, and the specialized image, video, and news extensions used by Google and Bing. Rather than letting malformed sitemaps slip through to a search console, it enforces the protocol’s constraints — URL counts, location length, priority ranges, and per-type limits — at struct construction time, so invalid data fails fast in your code instead of silently degrading your SEO.
What You Get
- Builders for URL, index, image, video, and news sitemaps that serialize to spec-compliant XML
- Compile-in validation that rejects oversized location strings, excess URLs, and invalid priorities at struct creation
- A safe, dependency-light API with
unsafecode forbidden and strict clippy lints enforced
Common Use Cases
- Generating sitemaps for a Rust-powered website or static-site generator at build time
- Producing image, video, or Google News sitemaps with their extension-specific fields
- Splitting a large site across a sitemap index when a single file would exceed protocol limits
Under The Hood
Architecture - The crate models each sitemap type as its own module (url_set, sitemap_index, image, video, news) with a builder pattern for the record types that carry many optional fields, notably UrlBuilder and VideoBuilder. Validation lives in dedicated error enums (UrlError, UrlSetError, SitemapIndexError, VideoError) returned at build time, so a UrlSet cannot be constructed in an invalid state. Tech Stack - It targets the Rust 2024 edition (rust-version 1.89) and relies on the xml-builder and chrono crates for serialization and date handling; the build is linted aggressively with clippy pedantic/cargo groups set to deny. Code Quality - The repository forbids unsafe_code at the crate level, enforces an extensive clippy configuration, and carries an integration test suite under tests/ covering each sitemap variant. API Design - The builder-plus-validation approach makes the happy path ergonomic while surfacing spec violations as typed Result errors, so misuse is caught by the compiler and at runtime rather than by an external search console.