From 4c890b59799567f5f4a0d10b11dca305c4cdeb93 Mon Sep 17 00:00:00 2001 From: altrdev Date: Fri, 23 Oct 2026 12:19:04 +0200 Subject: [PATCH] docs: publish a sitemap for search engines Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/docs.yml | 4 ++++ CHANGELOG.md | 5 +++++ book/sitemap.py | 25 +++++++++++++++++++++++++ book/src/development.md | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 book/sitemap.py diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index bd507a5..a54820f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index cdbedb9..f6402db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/book/sitemap.py b/book/sitemap.py new file mode 100644 index 0000000..47339f8 --- /dev/null +++ b/book/sitemap.py @@ -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 += [f' {url}' for url in urls] +xml.append('') +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') diff --git a/book/src/development.md b/book/src/development.md index 7f26090..dc385e2 100644 --- a/book/src/development.md +++ b/book/src/development.md @@ -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