Skip to content

MkDocs

MkDocs is a Python-based static site generator designed for project documentation. It outputs a fully static site to site/ by default. pageflare integrates as a post-build step — chain it after mkdocs build.

Works with both the default theme and Material for MkDocs.

Terminal window
# Shell (Linux/macOS)
curl -fsSL https://get.appz.dev/pageflare/install.sh | sh
# Homebrew
brew tap getappz/tap && brew install pageflare
# npm (if you have Node.js available)
npm install -g @pageflare/cli

Run pageflare after MkDocs builds:

Terminal window
mkdocs build && pageflare site/ --in-place

Create a pageflare.jsonc in your project root:

pageflare.jsonc
{
"minify_html": true,
"minify_css": true,
"minify_js": true,
"js_defer": true,
"lazy_images": true,
"img_dimensions": true,
"font_swap": true,
"preconnect_hints": true
}

If you use a custom output dir (mkdocs build -d build/), pass the same path:

Terminal window
mkdocs build -d build && pageflare build/ --in-place

MkDocs (and Material for MkDocs) handles theming and navigation but does not optimize the final output. pageflare adds:

  • HTML, CSS, and JS minification
  • Lazy loading and image dimension inference
  • JavaScript defer and loader injection
  • Font display swap and self-hosting
  • Preconnect hints for third-party origins
  • Critical CSS extraction (Pro)
  • Responsive image srcset generation (Pro)

Material for MkDocs has a built-in minify plugin. You can use both — Material handles HTML minification, pageflare handles everything else:

pageflare.jsonc
{
"minify_html": false,
"minify_css": true,
"minify_js": true
}

Or let pageflare handle all minification and skip the Material plugin.

.github/workflows/docs.yml
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install MkDocs
run: pip install mkdocs mkdocs-material
- name: Build docs
run: mkdocs build
- name: Optimize with pageflare
uses: getappz/pageflare-cli@v1
with:
args: "site/ --in-place"
netlify.toml
[build]
command = "mkdocs build && pageflare site/ --in-place --no-progress"
publish = "site"
vercel.json
{
"buildCommand": "pip install mkdocs && mkdocs build && pageflare site/ --in-place --no-progress"
}

Read the Docs uses its own build pipeline and does not support post-build hooks. To use pageflare, switch to a self-hosted deployment with GitHub Actions or Netlify.

MkDocs has Python-based plugins for optimization. After adding pageflare, you can remove:

Pluginpageflare equivalent
mkdocs-minify-pluginHTML minification
mkdocs-redirectsKeep — pageflare doesn’t handle redirects

Set the PAGEFLARE_LICENSE environment variable to unlock Pro optimizations:

Terminal window
PAGEFLARE_LICENSE=your-key mkdocs build && pageflare site/ --in-place

MkDocs static output works with any hosting provider:

pageflare processes 0 files Verify the output directory — MkDocs defaults to site/ but this can be changed via site_dir in mkdocs.yml.

Search broken after optimization MkDocs search relies on search_index.json. pageflare does not modify JSON files, so search should work normally. If search breaks, check that JS deferral isn’t delaying the search script — disable it if needed:

{ "js_defer": false }

Font loading issues with Material theme Material for MkDocs loads Google Fonts by default. pageflare’s font self-hosting feature will download and serve them locally, which is usually faster. If you see font rendering issues, check that self_host_google_fonts is working correctly by inspecting the generated CSS.