<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sonneko</title>
    <description>The latest articles on DEV Community by Sonneko (@ku_0dfe543e8243f19f5).</description>
    <link>https://dev.to/ku_0dfe543e8243f19f5</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3210106%2F373f3df8-1632-4100-9b97-5b50141953dd.jpeg</url>
      <title>DEV Community: Sonneko</title>
      <link>https://dev.to/ku_0dfe543e8243f19f5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ku_0dfe543e8243f19f5"/>
    <language>en</language>
    <item>
      <title>I made a sitemap generator for mdBook. It was my first time releasing a crate!</title>
      <dc:creator>Sonneko</dc:creator>
      <pubDate>Sun, 14 Jun 2026 01:21:30 +0000</pubDate>
      <link>https://dev.to/ku_0dfe543e8243f19f5/i-made-a-sitemap-generator-for-mdbook-it-was-my-first-time-releasing-a-crate-53ge</link>
      <guid>https://dev.to/ku_0dfe543e8243f19f5/i-made-a-sitemap-generator-for-mdbook-it-was-my-first-time-releasing-a-crate-53ge</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I'm in high school in Japan. I'm afraid that this article may include some unnatural points.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

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

&lt;p&gt;&lt;em&gt;mdBook&lt;/em&gt; has a rich ecosystem to expand its functionality.  Luckily I found &lt;em&gt;mdbook-sitemap-generator&lt;/em&gt; that supports  my project.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/rxdn" rel="noopener noreferrer"&gt;
        rxdn
      &lt;/a&gt; / &lt;a href="https://github.com/rxdn/mdbook-sitemap-generator" rel="noopener noreferrer"&gt;
        mdbook-sitemap-generator
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Utility to generate a sitemap.xml file for an mdbook project
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;mdbook-sitemap-generator&lt;/h1&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;What is this?&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;mdbook-sitemap-generator is a simple utility to generate sitemap.xml files for mdbook projects.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Installation&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;Binaries are distributed on the &lt;a href="https://github.com/rxdn/mdbook-sitemap-generator/releases" rel="noopener noreferrer"&gt;Github Releases Page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It is also possible to install this utility via cargo, using &lt;code&gt;cargo install mdbook-sitemap-generator&lt;/code&gt;.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Usage&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;The utility should be run from the root of the project.&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;USAGE:
    mdbook-sitemap-generator [OPTIONS] --domain &amp;lt;DOMAIN&amp;gt;

OPTIONS:
    -d, --domain &amp;lt;DOMAIN&amp;gt;
    -h, --help               Print help information
    -o, --output &amp;lt;OUTPUT&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When running the utility, you must pass the site's domain on URL via the &lt;code&gt;-d&lt;/code&gt; flag, for example, &lt;code&gt;-d docs.example.com&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If the &lt;code&gt;-o&lt;/code&gt; flag is not passed, the sitemap will be written to stdout.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;$ ls
book  book.toml  src
$ mdbook-sitemap-generator -d docs.example.com -o book/sitemap.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/rxdn/mdbook-sitemap-generator" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;However, it doesn't support the latest version of &lt;em&gt;mdBook&lt;/em&gt;. 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  LLM Assisted Coding
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manual Coding
&lt;/h2&gt;

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

&lt;p&gt;I read mdBook documents and found JSON form mismatch. I revised the code and check if the integration test pass.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;trait&lt;/span&gt; &lt;span class="n"&gt;Tester&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Sized&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;init_book_toml&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;'static&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;init_mock_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src_dir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;validate_sitemap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;book_dir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;run_test&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// 1. initialize virtual file system&lt;/span&gt;
        &lt;span class="c1"&gt;// 2. make virtual book.toml&lt;/span&gt;
        &lt;span class="c1"&gt;// 3. make src/ SUMMARRY.md and each sections&lt;/span&gt;
        &lt;span class="c1"&gt;// 4. run mdBook build&lt;/span&gt;
        &lt;span class="c1"&gt;// 5. validate generated sitemap.xml&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I made Tester trait and make it easy to add various integration tests. If you want to see concrete implementation, see github.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sonneko/mdbook-sitemap/blob/main/tests/mod.rs" rel="noopener noreferrer"&gt;https://github.com/sonneko/mdbook-sitemap/blob/main/tests/mod.rs&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to use it
&lt;/h2&gt;

&lt;p&gt;No complex configuration is required! Just install through cargo and add very simple configurations on your book.toml.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo &lt;span class="nb"&gt;install &lt;/span&gt;mdbook-sitemap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[output.sitemap]&lt;/span&gt;
&lt;span class="py"&gt;base-url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://example.com/docs"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Please feel free to use &lt;em&gt;mdbook-sitemap&lt;/em&gt;. I'd appreciate it if you would give it a star.&lt;/p&gt;

&lt;p&gt;Github: &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sonneko" rel="noopener noreferrer"&gt;
        sonneko
      &lt;/a&gt; / &lt;a href="https://github.com/sonneko/mdbook-sitemap" rel="noopener noreferrer"&gt;
        mdbook-sitemap
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Tool to generate a sitemap.xml file for an mdBook project
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;mdbook-sitemap&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://crates.io/crates/mdbook-sitemap" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/ef2676844a7c5d6495b4e9f27ca78186f646f2c5c9f2bf1a5e16d7f0b91d9b2c/68747470733a2f2f696d672e736869656c64732e696f2f6372617465732f762f6d64626f6f6b2d736974656d61702e737667" alt="Crates.io"&gt;&lt;/a&gt;
&lt;a href="https://opensource.org/licenses/MIT" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667" alt="License: MIT"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Tool to generate a sitemap.xml file for an mdbook project&lt;/p&gt;
&lt;p&gt;This tool is an mdBook backend that automatically generates a sitemap.xml&lt;/p&gt;
&lt;p&gt;file when &lt;code&gt;mdbook build&lt;/code&gt; is run. It reads the book structure from stdin
(as JSON provided by mdbook) and writes sitemap.xml to the output directory.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Usage&lt;/h1&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;mdbook-sitemap&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;cargo install mdbook-sitemap&lt;/pre&gt;

&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Add config to your &lt;code&gt;Book.toml&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight highlight-source-toml notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;[&lt;span class="pl-en"&gt;output&lt;/span&gt;.&lt;span class="pl-en"&gt;html&lt;/span&gt;]

[&lt;span class="pl-en"&gt;output&lt;/span&gt;.&lt;span class="pl-en"&gt;sitemap&lt;/span&gt;]
&lt;span class="pl-smi"&gt;base-url&lt;/span&gt; = &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;https://example.com/docs/&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Optional settings:&lt;/span&gt;
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; change-freq = "weekly"          # always|hourly|daily|weekly|monthly|yearly|never&lt;/span&gt;
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; priority = 0.7                  # 0.0 - 1.0&lt;/span&gt;
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; output-filename = "sitemap.xml" # output filename&lt;/span&gt;
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; include-draft = false           # whether to include draft chapters&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Licence&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;MIT license&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sonneko/mdbook-sitemap" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;Crates.io&lt;br&gt;
&lt;a href="https://crates.io/crates/mdbook-sitemap" rel="noopener noreferrer"&gt;https://crates.io/crates/mdbook-sitemap&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>mdbook</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
