Documentation Site Architecture
This file documents non-obvious architectural decisions for the docs site (mthds.ai). Read this before modifying anything under docs/.
Site Architecture Overview
- MkDocs Material with
mikeversioning, published atmthds.ai site_urlishttps://mthds.ai/(bare domain) — mike adds the/latest/prefix to sitemap URLs without doubling- Canonical URLs are hardcoded to
https://mthds.ai/latest/in thesite_metablock override inmain.html - Custom domain via
docs/CNAME(value:mthds.ai) - Theme overrides live in
docs/overrides/
The Two 404 Pages (critical — do not conflate)
There are two distinct 404 pages serving different purposes:
-
docs/404.html— Standalone root-level fallback for GitHub Pages. Copied to/404.htmlongh-pagesbydocs-deploy-root. Contains JS redirect logic (unversioned URLs →/latest/...). Has its own styling (grayscale palette, dark mode viaprefers-color-scheme). NOT part of the MkDocs build. -
docs/overrides/404.html— MkDocs Material template override. Controls the versionedsite/404.htmlrendered by MkDocs. Extendsmain.html. Must include both SEO tags (noindex, canonical) AND visible user-facing content (heading + link back to/latest/).
There must be NO docs/404.md — a Markdown 404 would be treated as content, appear in the sitemap, and create an indexable /latest/404/ URL.
SEO Architecture
docs/overrides/main.html— Overrides thesite_metablock to hardcode canonical URLs tohttps://mthds.ai/latest/(sincesite_urlis the bare domain). Also owns OG tags (og:type,og:site_name,og:locale), Twitter cards, and JSON-LD for all pages. Usescanonical_latestvariable for all URL references. Conditionally emitsog:type=website+ WebSite JSON-LD on the homepage, andog:type=article+ TechArticle JSON-LD on all other pages. Organization JSON-LD appears on every page. Also contains the PostHog analytics snippet.docs/overrides/404.html— Extendsmain.html, addsnoindex/nofollow+ canonical back to/latest/. Must also render visible content.docs/.meta.yml— Default frontmatter for all pages viameta-managerplugin (description, keywords).- Per-page
descriptionfrontmatter in individual.mdfiles overrides the default.
site_url Is the Bare Domain
site_url is set to https://mthds.ai/ (bare domain, no /latest/). This prevents double-path bugs in the sitemap: MkDocs generates URLs relative to site_url, then mike adds the version prefix. If site_url included /latest/, mike would create /latest/latest/page/ URLs.
Canonical URLs are hardcoded to include /latest/ via the site_meta block override in main.html, so they point to real pages. OG URLs and JSON-LD also use the hardcoded canonical_latest variable.
robots.txt and sitemap.xml
MakefileROOT_ROBOTS_TXT— The authoritative robots.txt deployed to domain root bydocs-deploy-root. Allows/latest/and/sitemap.xml, disallows everything else. PointsSitemap:to the roothttps://mthds.ai/sitemap.xml.- Root
sitemap.xml— Generated bydocs-deploy-rootfromlatest/sitemap.xmlvia sed rewrite to ensure all URLs use/latest/paths. This root copy is what Google crawls (the versioned copy inside/latest/is not rewritten by mike). - There is no
docs/robots.txtinside the versioned site. If one is added, note that crawlers would ignore it (RFC 9309: only domain-root robots.txt is authoritative).
Mike Redirect Template
docs/overrides/redirect.html — Custom template used by the mike plugin for version alias redirects. Contains full OG/Twitter metadata and noindex, follow so redirects pass link equity without being indexed. Referenced in mkdocs.yml via redirect_template: docs/overrides/redirect.html.
Deployment (docs-deploy-root)
The docs-deploy-root Makefile target deploys root assets (404.html, robots.txt, index.html, sitemap.xml, mthds_schema.json) directly to the gh-pages branch via a temporary git worktree. The root sitemap.xml is generated from latest/sitemap.xml with paths normalized to /latest/.
- Called automatically after
docs-deploy-stableanddocs-deploy-specific-version - The root
index.htmlis a meta-refresh redirect to/latest/
Search Configuration
The search plugin uses separator: '[\s\-\.]+' to properly tokenize hyphenated and dotted identifiers like mthds-agent, METHODS.toml, domain.Name.
MkDocs Plugins
mike— versioning with copy-based aliasessearch— site search with custom separator for dotted/hyphenated termsprivacy— downloads external assets locally (GDPR) and addstarget: _blankto external linksmeta-manager— appliesdocs/.meta.ymldefaults to all pagesglightbox— image lightboxllmstxt-md— generatesllms.txtfor LLM-friendly content
Common Mistakes to Avoid
- Do NOT create
docs/404.md— it poisons the sitemap with an indexable/latest/404/URL - Do NOT delete
docs/overrides/404.html— it controls the versioned 404 page - Do NOT put 404-specific SEO tags in
main.html— that'soverrides/404.html's job - Do NOT change
site_urlto include/latest/— mike would create double-path URLs like/latest/latest/page/in the sitemap - When adding pages, update BOTH the
nav:section AND thellmstxt-mdpluginsections:inmkdocs.yml