Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ jobs:
cp skills/torchio/SKILL.md book/book/SKILL.md
grep -q '^name: torchio$' book/book/SKILL.md

# for search engines: the list of the pages, and the robots.txt that points to it
- name: Publish sitemap.xml and robots.txt next to the pages
run: python3 book/sitemap.py book/book

- name: Every link between the pages has a target
run: python3 book/check-links.py book/book

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project are documented here. The GitHub release of each version uses the matching section.

## Unreleased

### Documentation
- The site has a `sitemap.xml` and a `robots.txt` that points to it, so that search engines can index every page.

## 4.6.2 - 2026-10-20

### Changed
Expand Down
25 changes: 25 additions & 0 deletions book/sitemap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
"""Writes sitemap.xml and robots.txt for the site, from the pages of the book in the order of SUMMARY.md.
Usage: python3 book/sitemap.py book/book (after mdbook build book)"""
import os
import re
import sys

out = sys.argv[1]
src = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src')
site = 'https://' + open(os.path.join(src, 'CNAME')).read().strip()

urls = [f'{site}/']
for line in open(os.path.join(src, 'SUMMARY.md')):
m = re.match(r'^\s*-?\s*\[[^\]]+\]\(([^)]+)\.md\)', line)
# the first page of the book is the home page, already listed
if m and m.group(1) != 'introduction':
assert os.path.exists(os.path.join(out, m.group(1) + '.html')), f'{m.group(1)}.html is not in {out}'
urls.append(f'{site}/{m.group(1)}.html')

xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">']
xml += [f' <url><loc>{url}</loc></url>' for url in urls]
xml.append('</urlset>')
open(os.path.join(out, 'sitemap.xml'), 'w').write('\n'.join(xml) + '\n')
open(os.path.join(out, 'robots.txt'), 'w').write(f'User-agent: *\nAllow: /\n\nSitemap: {site}/sitemap.xml\n')
print(f'sitemap.xml: {len(urls)} pages')
2 changes: 1 addition & 1 deletion book/src/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ src/
assets/ui.html the control panel, a single static page
tests/ integration tests, by area
deploy/ Kubernetes manifests and the Helm chart
book/ this documentation, with mdBook (`SUMMARY.md` is the list of pages); `llms.py` writes llms.txt from it
book/ this documentation, with mdBook (`SUMMARY.md` is the list of pages); `llms.py` writes llms.txt and `sitemap.py` writes sitemap.xml from it
skills/torchio/ the skill that tells an agent how to run a test, published at /SKILL.md
examples/ the reference of the endpoints, written from the catalog
Dockerfile builds the binary for both platforms with cargo-zigbuild, into an image of one file
Expand Down
Loading