#seo #web-dev #html #html-generator

bin+lib sitemap-gen

A robust Rust library designed for efficient generation and optimization of sitemaps, supporting various formats and customizations

1 unstable release

0.0.1 Oct 10, 2024

#3 in #seo

Download history 114/week @ 2024-10-04 92/week @ 2024-10-11 19/week @ 2024-10-18 68/week @ 2024-10-25 71/week @ 2024-11-01 129/week @ 2024-11-08 28/week @ 2024-11-15 31/week @ 2024-11-22 55/week @ 2024-11-29 79/week @ 2024-12-06

202 downloads per month
Used in 3 crates (via staticdatagen)

MIT/Apache

72KB
1K SLoC

Sitemap Gen logo

Sitemap Gen (sitemap-gen)

A fast and efficient Rust library for generating and validating XML sitemaps.

Made With Love Crates.io lib.rs Docs.rs Codecov Build Status GitHub

WebsiteDocumentationReport BugRequest FeatureContributing Guidelines

Overview

The sitemap-gen library provides a powerful solution for generating and optimizing XML sitemaps, essential for enhancing SEO and improving website visibility. It supports the creation of sitemaps for websites of any scale, with built-in validation and performance optimizations to ensure that your sitemaps comply with web standards.

Features

  • XML Sitemap Generation: Efficiently generate well-structured XML sitemaps for websites.
  • URL Management: Add, validate, and normalize URLs easily within the sitemap.
  • Change Frequency Support: Specify how often pages are likely to change (daily, weekly, etc.).
  • Last Modified Dates: Include accurate timestamps for when pages were last modified.
  • Validation: Ensure that your sitemap adheres to size and URL limits as per SEO guidelines.
  • Performance Optimizations: Pre-allocate buffers and optimize memory usage for generating large sitemaps.
  • Asynchronous Processing: Leverage async functionality to generate sitemaps efficiently for larger sites.

Installation

Add this to your Cargo.toml to start using sitemap-gen:

[dependencies]
sitemap-gen = "0.0.1"

Usage

Here’s an example of how to generate a sitemap:

use sitemap_gen::{Sitemap, ChangeFreq, SiteMapData};
use url::Url;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a new sitemap
    let mut sitemap = Sitemap::new();

    // Add entries
    let entry = SiteMapData {
        loc: Url::parse("https://example.com/")?,
        lastmod: "2023-10-01".to_string(),
        changefreq: ChangeFreq::Weekly,
    };

    sitemap.add_entry(entry)?;

    // Generate the XML
    let xml = sitemap.to_xml()?;
    println!("{}", xml);

    Ok(())
}

Documentation

Full API documentation is available at docs.rs/sitemap-gen.

Examples

To explore more examples, clone the repository and run the following command:

cargo run --example example_name

Contributing

We welcome contributions from the community! Please check our contributing guidelines and feel free to submit issues or pull requests.

License

This project is licensed under either of the following licenses:

You can choose which one you prefer.

Acknowledgements

Special thanks to all contributors who have helped build and improve the sitemap-gen library.

Dependencies

~32–46MB
~730K SLoC