Skip to the content.

0012: A package site standard

Status: accepted. Author: drafted by the AI operations agent at Le Chen’s request. Created: 2026-11-08. Revised: 2026-11-09, after a field review. Decided: 2026-11-09, accepted by Le Chen (maintainer of record). Implemented in: (release).

Summary

A package’s documentation site gets one standard that lean-pkg can check, keep current and create. lean-pkg site check NAME reads a site of any of the three kinds package sites use today (Jekyll with a layout of its own, MkDocs Material, and a static site served as committed) and reports, offline, what is stale, missing or served by mistake. lean-pkg site render NAME writes the generated pages and the generated blocks inside hand-written pages, including the counts, versions and commits a landing page quotes, and keeps the site out of search indexes while the package is private. lean-pkg site init NAME writes a new site’s scaffold, with the noindex already in it. site check --live URL checks the published site over the network. publish gains a site item, and warns about a site that has not opted in. The check comes first, so every existing site can use it before any migration.

Motivation

lean-pkg renders the content of a package page: the README block between the lean-pkg:page markers (page --write), verification.md and coverage.md (page --site DIR), and one static HTML file (page --html). For the site around those pages, docs/page.md says only that the two pages go into the site’s navigation by hand. Everything else is assembled by hand, and package sites have ended up in three kinds:

Building by hand fails in known ways:

Design

Site kinds and the opt-in

site check detects the kind from the site directory DIR (default docs, relative to the repository root):

Kind Detected by Where the head (noindex, mathematics) goes Navigation
jekyll DIR/_config.yml, no .nojekyll the layout the pages use, DIR/_layouts/default.html (theme: null) the landing page’s links
mkdocs mkdocs.yml at the repository root whose docs_dir is DIR (MkDocs’ default is docs, so a file without the key is a site of docs/) the custom_dir override, main.html, blocks extrahead and scripts; MathJax and the fence converter there or in extra_javascript nav in mkdocs.yml
static DIR/.nojekyll each served .html file the landing page’s links

A site opts in with one key that its host ignores: lean_pkg_site: 1 in _config.yml (jekyll), under extra: in mkdocs.yml (mkdocs), or in a small DIR/lean-pkg-site.yaml (static). site check runs on any site, opted in or not. On a static site, site render fills only marked blocks inside the served .html files (an HTML comment marks a block there as anywhere else) and never writes a whole file, because every page there is a hand-built file; site init does not create static sites. No lean-pkg file format changes: the registry, coverage.yaml, receipts and index entries are untouched.

A site made by hand has a head without lean-pkg’s block. lean-pkg never rewrites a head it did not write: site check accepts the noindex meta tag itself, with or without the block, and site render on a head without the block names the file, prints the block to paste into it, and exits 1. site init writes a head that has the block already.

For a jekyll site, lean-pkg owns a minimal layout instead of relying on a theme’s head include: the pages-themes include _includes/head-custom.html, minima includes custom-head.html, and a theme: null site includes neither, so a tag written there would never reach the page. The layout pins MathJax 3.2.2 with its integrity hash and loads the fence converter, as the working sites do. For an mkdocs site, the generated configuration sets pymdownx.arithmatex: {generic: true} (for $...$ and \(...\) in prose) and pymdownx.highlight: {pygments_lang_class: true} (without it a latex fence has no language-latex class), loads MathJax and the fence converter (arithmatex does not convert fences), and adds two fixes the field sites needed: a partials/source.html without data-md-component="source" (Material’s repository widget calls the GitHub API anonymously and fails on a private repository), and .md-typeset td code {word-break: normal; overflow-wrap: normal}, so long Lean names are not split mid-name at phone width.

The fence converter

lean-pkg’s pages put a paper’s formula in a ```latex code fence, which GitHub shows as source. On the site, a small script lean-pkg owns turns each pre > code.language-latex into a display formula and keeps the TeX source behind a toggle. It ships as a file in the site (assets/lean-pkg-math.js), never from a CDN, and it configures MathJax with the require and autoload extensions disabled, so that the text of a statement cannot load MathJax extensions. On MkDocs Material, which replaces the page without reloading it, the script typesets again on each document$ emission but skips the first, because typesetting a page twice blanks every formula. site render writes the file and site check compares it with the version lean-pkg ships.

lean-pkg site check NAME [--dir DIR] [--json]

Offline and read-only, on every kind. Exit 0 when every check passes, 1 when one fails, 2 for a usage error:

--json: {ok, dir, kind, opt_in, stale[], links {missing[]}, html_blocks[], counts[], exemptions[], math {problems[]}, noindex {expected, present, files[]}, served {build_input_copies[], unclassified[]}, shadowing_index_html, binding {docs_descendant, reason}, snapshot {source, stale}, problems[]}.

lean-pkg site check NAME --live URL

The same command with the network, never run by publish. It fetches, without a browser: every generated page, llms.txt and CITATION.cff (each must return HTTP 200); the noindex meta tag in the served HTML, expected exactly as offline; and the commit GitHub Pages last deployed (pages/builds/latest), which must be the current commit or an ancestor that differs from it only in files the site does not read: outside DIR for jekyll and static, and outside DIR, mkdocs.yml, the custom_dir and any hooks for mkdocs. These are the failures only a live check catches: pages that return 404 under .nojekyll although a preview passed, Markdown blocks served raw for weeks while github.com showed them correctly, and a workflow-deployed site never deployed. Layout checks at phone, tablet and desktop width need a browser and are left to a later proposal.

Generated blocks

Hand-written text stays hand-written; numbers move into blocks lean-pkg fills. A block is delimited by <!-- lean-pkg:site:BLOCK --> and <!-- lean-pkg:site:end --> in a Markdown page, a served .html file, the README, or llms.txt. The blocks are the status capsule, the counts (claims, verified, conditional and excluded scopes from coverage.yaml and the claims ledger, theorems in the inventory), the package and lean-pkg versions and the commit the receipts bind, the install line and the citation line.

A count lean-pkg cannot derive yet (one taken from a coverage map outside the repository, or from a cluster receipt) is either moved into coverage.yaml as rows that name claim ids, or kept in hand-written text behind <!-- lean-pkg:site:exempt SOURCE -->, which site check reports with its source. An exemption does not cover a quantity lean-pkg derives: when the exempt text counts claims, scopes or inventory theorems, or states the package version, site check compares the value and fails when it differs.

A page rendered from a commit no gate receipt binds (a draft) gets a generated banner saying so, inside the block, so that the page and the banner cannot disagree.

lean-pkg site render NAME [--dir DIR] [--check] [--json]

On an opted-in jekyll or mkdocs site, writes atomically, from the record, the recorded receipts, coverage.yaml, CITATION.cff and LICENSE (on a static site, only the marked blocks):

File Content
verification.md, coverage.md byte for byte what page --site DIR writes
cite.md the preferred citation and the software citation from CITATION.cff, and the DOIs the record holds
license.md the SPDX license and a link to LICENSE, and the acknowledgments page derives from coverage.yaml
every file with lean-pkg:site: blocks only those blocks; the text around them is kept
the head (the layout or the override) only its marked block: the noindex tags while the record is private, empty once public; a head without the block is reported with the block to paste
assets/lean-pkg-math.js the fence converter
lean-pkg-site.json (package directory) the record snapshot (Running the check in CI)

render never overwrites a whole file that does not begin with lean-pkg’s Generated by note: a hand-written verification.md under the same name is reported, and render exits 1 until the author renames it or replaces it. llms.txt has one source, the repository’s root file; a served copy under DIR is written from it with its links resolved for where it is served. The noindex meta tag does not cover llms.txt or other plain-text files the site serves; docs/site.md says so.

With --check, nothing is written and the command exits 1 if any generated file or block differs, naming it.

lean-pkg site init NAME [--dir DIR] [--kind jekyll|mkdocs] [--dry-run] [--json]

Writes only files that do not exist: the configuration with the opt-in key, the head (layout or override) with the noindex block already filled while the record is private, the landing page with the three front doors (use it, check it, cite it) and their generated blocks, and, for mkdocs, the nav and the two fixes above. An existing file is never overwritten; the command lists it with what it would have contained.

publish and promote

Running the check in CI

A package’s CI cannot read a private registry, and most of the checks need the record: current (the generated pages are rendered from it), noindex (the visibility), binding and served files (the build_inputs and the docs_descendants veto), the license line and cite.md (license_spdx, the DOIs). So site render also writes a record snapshot, lean-pkg-site.json in the package directory: exactly the record fields the site uses (name, visibility, license_spdx, the DOIs, build_inputs, docs_descendants, and the recorded receipts’ paths and hashes), committed with the site.

The global --registry keeps working for a CI that can read the registry.

Subdirectory packages

The site belongs to the repository. --dir is relative to the repository root; for a jekyll site served by GitHub Pages from a branch it must be docs or the root, and site check refuses any other directory for that kind. An mkdocs site built by a workflow can live anywhere. Two packages in one repository cannot claim the same directory; the package pages go in a subdirectory of the site. lean-pkg-binding.yaml stays in the package directory, so the docs-only descendant rule is unchanged.

Documentation

A new guide, docs/site.md, holds the standard: the three front doors (README, site, llms.txt) and what each is for, the three site kinds, how mathematics is written so that it renders on GitHub and on the site, how the noindex works on a project site (the meta tag; robots.txt takes effect only at the root of a user or organization site; neither covers plain-text files), what the served-files check expects, and the commands above. docs/page.md points to it.

Implementation in phases

Each phase is its own pull request with its own record entry:

  1. site check (offline, all three kinds) and docs/site.md. Every existing site can use it at once.
  2. site render: the generated pages, the generated blocks (counts, version, commit, llms.txt), the noindex block, the fence converter, the record snapshot and the draft banner; site check --live URL.
  3. site init, the publish item and warning, and the promote lines.

init comes last because every site that needs the standard exists already. From phase 1, site check reports a private site without the noindex; from phase 3, site init writes it into every site it creates.

Compatibility and migration

Trust model

This changes nothing a receipt proves or gate, promote or index check accepts. publish gains an item that can fail for a package that opted in, and a warning for one that did not. Nothing that failed before passes now.

The generated pages and blocks are derived from the same inputs as page, so they cannot claim more than the page does. Hand-written prose outside the blocks is still not checked for what it says about the mathematics; the count rule catches the commonest drift. The noindex is advisory: well-behaved crawlers honor it, others need not, it does not cover plain-text files, and it does not restrict who can open the site.

A commit made by site render after the gate (removing the noindex after promote, or refreshing a count) keeps the receipts bound only when the new HEAD is a docs-only descendant of the gated commit X (docs/receipts.md, “Docs-only descendants”):

site check and promote’s next: lines report which case applies; when the commit is not a docs-only descendant, the package needs a re-gate. An offline pass also does not mean the live site changed: for a site deployed by a workflow run by hand, the commit deploys nothing until the workflow runs, which --live detects.

Alternatives

Open questions

  1. Whether render should ever convert a static site to another kind, or leave that to the author with docs/site.md.
  2. The exact list of quantities the count rule recognizes outside generated blocks (proposed: integers next to the words the generated blocks use, lean-pkg and package versions, and hexadecimal commits of 7 or more characters).
  3. Whether the browser layout checks (overflow, MathJax errors, broken Lean names at three widths) come in a later proposal or stay outside lean-pkg.

AI assistance

Drafted and revised with Claude Code (Claude Opus 5.5) at Le Chen’s request, from a field request and a field review by other AI agents working on package sites; the facts about the existing sites were checked against their repositories. Le Chen reviews and decides.