惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Recent Announcements
Recent Announcements
雷峰网
雷峰网
The GitHub Blog
The GitHub Blog
罗磊的独立博客
月光博客
月光博客
J
Java Code Geeks
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
U
Unit 42
C
Check Point Blog
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
MyScale Blog
MyScale Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I made a sitemap generator for mdBook. It was my first ti...
Sonneko · 2026-06-14 · via DEV Community

Sonneko

I'm in high school in Japan. I'm afraid that this article may include some unnatural points.

Motivation

I'm creating a web document that explains systematically what programming is all about. I used mdBook, a static site generator written in Rust. However, I found it doesn't support Sitemap generation.

mdBook has a rich ecosystem to expand its functionality. Luckily I found mdbook-sitemap-generator that supports my project.

mdbook-sitemap-generator

What is this?

mdbook-sitemap-generator is a simple utility to generate sitemap.xml files for mdbook projects.

Installation

Binaries are distributed on the Github Releases Page.

It is also possible to install this utility via cargo, using cargo install mdbook-sitemap-generator.

Usage

The utility should be run from the root of the project.

USAGE:
    mdbook-sitemap-generator [OPTIONS] --domain <DOMAIN>

OPTIONS:
    -d, --domain <DOMAIN>
    -h, --help               Print help information
    -o, --output <OUTPUT>

When running the utility, you must pass the site's domain on URL via the -d flag, for example, -d docs.example.com.

If the -o flag is not passed, the sitemap will be written to stdout.

For example:

$ ls
book  book.toml  src
$ mdbook-sitemap-generator -d docs.example.com -o book/sitemap.xml


However, it doesn't support the latest version of mdBook. There was an alternative sitemap-generation backend but written in Go. We can't install it through cargo. So I decided to make my own alternative.

LLM Assisted Coding

I asked Claude Sonnet to generate a simple sitemap generator written in 100% Rust. The code claude made includes implementation and unit tests. The unit tests passed. However, there is one mistake in the JSON format that mdBook sends to the custom backend.

Manual Coding

I added to it simple CI flows for validating project and integration test that simulate the latest version of mdBook behavior. Thanks to this setup, I was able to notice it doesn't run correctly.

I read mdBook documents and found JSON form mismatch. I revised the code and check if the integration test pass.

trait Tester: Sized {
    fn init_book_toml() -> &'static str;

    fn init_mock_contents(src_dir: &Path);

    fn validate_sitemap(book_dir: &Path);

    fn run_test() {
        // 1. initialize virtual file system
        // 2. make virtual book.toml
        // 3. make src/ SUMMARRY.md and each sections
        // 4. run mdBook build
        // 5. validate generated sitemap.xml
    }
}

I made Tester trait and make it easy to add various integration tests. If you want to see concrete implementation, see github.

https://github.com/sonneko/mdbook-sitemap/blob/main/tests/mod.rs

How to use it

No complex configuration is required! Just install through cargo and add very simple configurations on your book.toml.

cargo install mdbook-sitemap

[output.sitemap]
base-url = "https://example.com/docs"

Conclusion

Please feel free to use mdbook-sitemap. I'd appreciate it if you would give it a star.

Github:

mdbook-sitemap

Crates.io License: MIT

Tool to generate a sitemap.xml file for an mdbook project

This tool is an mdBook backend that automatically generates a sitemap.xml

file when mdbook build is run. It reads the book structure from stdin (as JSON provided by mdbook) and writes sitemap.xml to the output directory.

Usage

  1. Install mdbook-sitemap
cargo install mdbook-sitemap

  1. Add config to your Book.toml
[output.html]

[output.sitemap]
base-url = "https://example.com/docs/"
# Optional settings:
# change-freq = "weekly"          # always|hourly|daily|weekly|monthly|yearly|never
# priority = 0.7                  # 0.0 - 1.0
# output-filename = "sitemap.xml" # output filename
# include-draft = false           # whether to include draft chapters

Licence

MIT license



Crates.io
https://crates.io/crates/mdbook-sitemap