# Sitewriter ![Rust](https://github.com/edg-l/sitewriter/workflows/Rust/badge.svg) [![crates.io](http://meritbadge.herokuapp.com/sitewriter)](https://crates.io/crates/sitewriter) ![License](https://img.shields.io/github/license/edg-l/sitewriter) A rust library to generate sitemaps. It uses the [quick-xml](https://github.com/tafia/quick-xml) so it should be fast. To handle the `lastmod` tag it uses [chrono](https://docs.rs/chrono/) but it can be disabled with `default-features = false`. ## Example To run the examples use `cargo run --example gen_sitemap` ```rust use chrono::prelude::*; use sitewriter::*; fn main() { let mut sitemap = Sitemap::new(); sitemap.urls.push(Url::new("https://edgarluque.com/projects")); sitemap.urls.push(Url { loc: "https://edgarluque.com/", changefreq: Some(ChangeFreq::Daily), priority: Some(1.0), lastmod: Some(Utc::now()), }); sitemap.urls.push(Url { loc: "https://edgarluque.com/blog", changefreq: Some(ChangeFreq::Weekly), priority: Some(0.8), lastmod: Some(Utc::now()), }); sitemap.urls.push(Url { loc: "https://edgarluque.com/blog/sitewriter", changefreq: Some(ChangeFreq::Never), priority: Some(0.5), lastmod: Some(Utc.ymd(2020, 11, 22).and_hms(15, 10, 15)), }); sitemap.urls.push(Url { loc: "https://edgarluque.com/blog/some-future-post", changefreq: Some(ChangeFreq::Never), priority: Some(0.5), lastmod: Some(Utc.from_utc_datetime(&Local.ymd(2020, 12, 5).and_hms(12, 30, 0).naive_utc())), }); let result = sitemap.into_str(); println!("{}", result); } ``` Prints the following: ```xml https://edgarluque.com/projects https://edgarluque.com/ 2020-11-22T14:36:30Z 1.0 daily https://edgarluque.com/blog 2020-11-22T14:36:30Z 0.8 weekly https://edgarluque.com/blog/sitewriter 2020-11-22T15:10:15Z 0.5 never https://edgarluque.com/blog/some-future-post 2020-12-05T11:30:00Z 0.5 never ```