Description
Themkdocs_hooks.py script intercepts static pages during compilation. It strips unnecessary docs/ prefixes and normalises repository-root relative paths (../../ to ../), ensuring links work seamlessly on both GitHub.com and built HTML servers.
Script path
tools/mkdocs_hooks.py
CLI integration
Automated by the static site compiler. Registered insidemkdocs.yml:
Functions
on_page_markdown(markdown, page, config, files)
Interceptors registered by the MkDocs lifecycle.
- Arguments:
markdowncontent (string),pagemetadata,configcontext,filescollection. - Returns: Modified Markdown string with rewritten relative URLs.
Rewriting rules
- External links: Keeps
http://,https://,mailto:,ftp:, and#anchor links unchanged. docs/prefix: Stripsdocs/from relative paths (e.g.docs/governance/PROTOCOL.mdbecomesgovernance/PROTOCOL.md).../../prefix: Normalises double-parent directories (e.g.../../AGENTS.mdbecomes../AGENTS.md).
Deep State of Mind (DSOM) For My AI Protocol | Harisfazillah Jamel (LinuxMalaysia) | 2026-08-14 Standard: UK English | DBP-standard Bahasa Melayu Malaysia (Piawai) | GNU General Public License v3.0