This directory contains the Starlight-based documentation website for ICP CLI.
The documentation site is built with Astro and Starlight, reading markdown files directly from the ../docs/ directory.
docs-site/
├── astro.config.mjs # Starlight configuration (sidebar, theme, SEO meta tags, JSON-LD)
├── versions.json # Version registry (controls root redirect and robots.txt)
├── plugins/
│ ├── rehype-rewrite-links.mjs # Rewrites .md links for Starlight's clean URLs
│ └── astro-agent-docs.mjs # Generates llms.txt, feed.xml, og-image.png, sitemap lastmod
├── src/
│ ├── content.config.ts # Content loader configuration
│ ├── components/ # Custom Starlight component overrides (Footer, Banner, SiteTitle)
│ ├── assets/ # Logo and static assets
│ └── styles/ # DFINITY theme CSS
├── public/
│ ├── og-image.svg # Source SVG for the social sharing image (converted to PNG at build time)
│ └── ... # Other static files (favicon, well-known, etc.)
└── package.json # Dependencies and scripts
- Uses Astro's
globloader to read directly from../docs/(excludingschemas/and README files) - Source docs use minimal YAML frontmatter (
title+description) - A rehype plugin rewrites
.mdlinks at build time for Starlight's clean URLs
- Starlight reads content directly from
../docs/via the glob content loader - Rehype plugin (
plugins/rehype-rewrite-links.mjs) strips.mdextensions from relative links and adjusts paths for Astro's directory-based output - DFINITY theme CSS is applied for consistent branding
- Static HTML is produced in
dist/ astro-agent-docsplugin runs in theastro:build:donehook and generates additional files:llms.txt— LLM/agent-friendly page index (agentdocsspec.com)llms-full.txt— full content dump for RAG pipelinesfeed.xml— RSS 2.0 feed with git-accurate publish dates per pageog-image.png— social sharing preview image, rendered frompublic/og-image.svgvia@resvg/resvg-js- Sitemap
<lastmod>injection — adds git commit dates to the Starlight-generated sitemap
Source docs use .md extensions in links (GitHub-friendly), and the rehype plugin transforms them to clean URLs at build time.
- Custom CSS for DFINITY branding
- Files:
layers.css,theme.css,overrides.css,elements.css - Maintains consistent look with other DFINITY documentation sites
- External links automatically open in new tabs with security attributes (
rel="noopener noreferrer") - Implemented via
rehype-external-linksplugin for content links - Custom script in
astro.config.mjshandles social/header links
- A feedback banner is shown on every page via a custom
Bannercomponent override (src/components/Banner.astro) - No per-page frontmatter needed — the component renders the same banner globally
- Sidebar is manually configured in
astro.config.mjs - This is required because Starlight's autogenerate doesn't work with glob loaders
- When adding new docs, update the sidebar configuration
npm installnpm run devOpens the site at http://localhost:4321
npm run buildOutputs to ./dist/
npm run previewnpm run cleanRemoves dist/ and .astro/ directories
dev- Cleans artifacts and starts development serverbuild- Builds for productionpreview- Previews production build locallyclean- Removes build artifacts (dist/,.astro/)test:versions- Simulates the full multi-version production layout locally for testing the version switcher UI
The site is hosted on an IC asset canister and served at https://cli.internetcomputer.org.
Canister ID: ak73b-maaaa-aaaad-qlbgq-cai
.github/workflows/docs.ymlbuilds documentation and pushes built files to thedocs-deploymentbranch (one directory per version:0.1/,0.2/,main/, etc.).github/workflows/docs-deploy.ymlis called bydocs.ymlafter publish jobs complete and deploys the entiredocs-deploymentbranch to the IC asset canister
-
Push to
main: Rebuilds/main/docs and root files (index.html,versions.json,robots.txt,sitemap.xml, IC config). Also copiesog-image.png,llms.txt,llms-full.txt, andfeed.xmlfrom the latest versioned deployment to the root. -
Release tags (
v*): Builds and deploys versioned docs (e.g.,v0.2.0→/0.2/). Also triggersdelete-docs-branch.ymlwhich automatically deletes thedocs/v0.2branch if one exists — preventing stale branches from re-deploying outdated content on accidental pushes. -
Docs-override branches (
docs/v*): Redeploys versioned docs for a specific minor version without cutting a new code release (e.g.,docs/v0.2→/0.2/). These branches are short-lived by design — created only for an immediate docs fix, then deleted automatically on the next release.To trigger a re-deploy, create a fresh branch from the latest release tag and push your fix:
git fetch origin git checkout -b docs/v0.2 v0.2.3 # start from the release tag, not stale state git cherry-pick <commit-sha> # commit must already be merged to main git push origin docs/v0.2
Several files must live at the deployment root (not inside a versioned subfolder) to be discovered correctly:
robots.txt— generated dynamically by the CIpublish-root-filesjob fromversions.json; allows only the latest version's path, disallows old versions, and disallows/main/(except when no releases exist yet and/main/is the fallback). Never placed in versioned build output.sitemap.xml— root sitemap index pointing directly to the latest version'ssitemap-0.xml(spec-compliant: a sitemapindex must reference sitemaps, not other sitemapindex files); generated bypublish-root-files.og-image.png— theog:imagemeta tag always referenceshttps://cli.internetcomputer.org/og-image.png. The CIpublish-root-filesjob copies it from the latest versioned build folder to root after each versioned deployment.llms.txt/llms-full.txt— same pattern asog-image.png;publish-root-filesprepends a version navigation header to the rootllms.txt.feed.xml— same pattern; copied from the latest versioned folder to root.
The old GitHub Pages site at https://dfinity.github.io/icp-cli/ redirects all paths to https://cli.internetcomputer.org/.
In astro.config.mjs:
site: Base URL (https://cli.internetcomputer.orgin production)base: Version path (set viaPUBLIC_BASE_PATH, e.g.,/0.2/,/main/)title,description: Site metadatalogo: ICP logo configurationfavicon: Site faviconcustomCss: DFINITY theme filesmarkdown.rehypePlugins: Link rewriting and external link handling
Manual sidebar definition in astro.config.mjs:
sidebar: [
{
label: 'Section Name',
items: [
{ label: 'Page Title', slug: 'path/to/page' },
// ...
],
},
// ...
]The slug should match the file path relative to docs/ without the .md extension.
- Create a
.mdfile in../docs/in the appropriate directory - Add YAML frontmatter with
titleanddescription - Write standard Markdown content (no H1 heading — Starlight renders the title)
- Add the page to the sidebar in
astro.config.mjs:{ label: 'Your Section', items: [ { label: 'Your New Page', slug: 'section/your-new-page' }, // ... ], }
Check that:
- The file exists in
../docs/with correct path - The file has YAML frontmatter with at least a
titlefield - The slug in
astro.config.mjsmatches the file path (without.md) - You ran
npm run devto trigger the build process
Check that:
- The source file in
../docs/does not have an H1 heading (thetitlefrontmatter is rendered as H1 by Starlight)
- Use relative links with
.mdextension in source docs:[text](./file.md) - The rehype plugin (
plugins/rehype-rewrite-links.mjs) strips.mdextensions and adjusts paths at build time - External links should use full URLs
- Source documentation in
../docs/uses minimal YAML frontmatter (title+description) - The
schemas/directory is excluded from the docs site (served via GitHub raw URLs)