Trailhead: moving from MkDocs

In your terminal ssqch docs --from mkdocs

MkDocs and SiteSquatch both build a site from a folder of Markdown and one config file. MkDocs' theme templates are Jinja, which ssqch renders with Jinja's filters, tests and methods on a fork of Nunjucks (.jinja files), so a custom theme or overrides/ folder ports with few changes (Jinja and Nunjucks lists where Nunjucks isn't Jinja: a {% set %} inside a loop keeps its value, and there is no {% break %}); Material for MkDocs' features map onto containers, hooks and the navigation helpers.

The docs-sidebar example is inspired by real-world docs sites: a sidebar from a YAML nav, a table of contents, admonitions, code from files and Pagefind search.

Scouting

ssqch scout (see Scouting a site) reads mkdocs.yml and the pages: each plugin and Markdown extension with ssqch's way to do it, and the MkDocs syntax the pages use, counted (links to .md files, admonitions, tabs, snippets, icons, mkautodoc's and mkdocstrings' ::: blocks), and what MkDocs writes on its own (search/search_index.json, 404.html, sitemap.xml.gz). Its reference build names the Python environment MkDocs needs (pip install -r requirements.txt, and a .venv's mkdocs when there is one). Its draft (--write-draft) is an ssqch.config.js that reads the pages as MkDocs writes them, with no page changed, and the nav as _data/nav.yml (titles from the nav, or each page's first heading). On Material for MkDocs' own docs, the draft built every page from a fresh checkout:

A whole move with the loop, scout's report before, halfway and at the end, with baseline and diff between: A move, step by step.

export default defineConfig({
  dirs: { input: "docs", output: "site", includes: "../_includes", data: "../_data" },
  base: "/mkdocs-material/",   // site_url's path
  markdownEngine: false,       // MkDocs doesn't run template code in pages
  markdown: { highlight: { classes: "pygments" } },
  passthrough: [{ "docs/**/*.png": "." }, { "docs/CNAME": "CNAME" }],   // MkDocs copies the docs folder's other files
  // MkDocs warns about a broken link unless strict: true, and so does the draft.
  // MkDocs' Markdown: Python-Markdown's reading, admonitions, tabs, toc's ids, `.md` links.
  plugins: [fromMkdocs(), sitemapPlugin({ url: "https://example.com/docs" }), redirectsPlugin({ redirects: { "/old/": "/new/" } }), linksPlugin({ fail: false })],
});

Besides the config, the draft writes _data/nav.yml from the nav and, for pymdownx.highlight or codehilite, a fence hook with their markup around highlighted code (hooks/fence.jinja, in the includes folder).

Run ssqch scout again once the draft is there. It loads your config, takes what the config does off the list and counts it as done. A two-page Material site's list went from 17 to 7 to do:

$ ssqch scout --write-draft
...
Wrote 3 draft files.
$ ssqch scout
Scouting the MkDocs site in . (found mkdocs.yml): a move under way, with ssqch.config.js

7 to do across 2 pages: 3 ssqch does, 2 an option does (the draft turns it on), 2 not in ssqch yet.
10 done already: ssqch.config.js has `dirs: { includes: "../overrides" }`, `fromMkdocs`, `markdown: { highlight: { classes: "pygments" } }`, `markdown: { definitionLists: true }`.
...

What stays: the theme (below), the plugins MkDocs has and ssqch doesn't yet (search_index.json, sitemap.xml.gz), the 404.html, things that are built in (custom fences, attr_list), and a plugin call such as redirectsPlugin(), which is listed for you to check. ssqch scout --format json has the same in todo and done.

fromMkdocs() from ssqch/from-mkdocs is MkDocs' Markdown as one plugin, each part a default your own markdown can change: dialect: "python-markdown" (a raw HTML block runs to its closing tag, lists nest at four spaces), admonitions and tabs as Material writes them, toc's heading ids (headingIds: "python-markdown") and .md links from the page (sourceLinks: "relative"). fromMkdocs({ templates: true, config: "mkdocs.yml" }) adds the theme's context, below.

The theme

fromMkdocs({ templates: true }) gives templates what MkDocs gives a theme's, so the theme's Jinja templates, Material for MkDocs' included, run as they're written: config (mkdocs.yml, with the theme's mkdocs_theme.yml under its theme), nav (MkDocs' Sections, Pages and Links, with active on the page being rendered), page (MkDocs' page, with content, toc, meta, previous_page and next_page), base_url, and the url and script_tag filters, which make URLs relative to the page. Each Markdown page renders with the theme's main.html (or its front matter's template), the theme's 404.html makes /404.html, and Jinja doesn't escape, as MkDocs' doesn't. ssqch docs fromMkdocs has the details.

A theme from pip is Python's, so copy its templates into an ssqch theme: the templates in _includes, the files to copy (assets/) beside it. For Material:

M=$(python -c "import material, os; print(os.path.dirname(material.__file__))")/templates
mkdir -p theme/_includes && cp -R "$M"/. theme/_includes/ && mv theme/_includes/assets theme/assets

In scout's draft, that's adding theme: "theme" and changing fromMkdocs() to fromMkdocs({ templates: true }). A config for the theme alone:

export default defineConfig({
  dirs: { input: "docs", output: "site", includes: "overrides" },   // theme.custom_dir, from docs_dir
  theme: "theme",
  markdownEngine: false,
  markdown: { highlight: { classes: "pygments" } },
  plugins: [fromMkdocs({ templates: true })],
});

On a real-world Material docs site of 24 pages, this config, with no template changed and no code of the site's own, built every page with Material's nav, table of contents, header and footer byte for byte as MkDocs wrote them; the differences left were highlighted code (Pygments' tokens), the two pages mkautodoc writes from Python, and the search index. What it doesn't do: MkDocs' plugins (Material's search index, sitemap.xml.gz, its blog and social cards), and Python's own code in hooks.

The config

mkdocs.ymlssqch.config.js
docs_dir, site_dirdirs: { input, output }
nav:_data/nav.yml, in the shape the nav helpers read: - { title: Install, url: /install/ }, with sections holding children (or items, pages). navTree(nav, page.url) marks the current page and its sections, navPager gives previous and next, navBreadcrumbs the trail.
theme: material and its optionsThe theme's own templates with fromMkdocs({ templates: true }) (The theme, below), or templates of your own (start from docs-sidebar)
theme.custom_dir / overrides/ (Jinja)The includes folder (dirs.includes, which the draft sets to it): read before a theme's, so a template there replaces the theme's of the same name; {% extends %}, blocks and macros work
extra:_data/site.yml
use_directory_urls: trueThe default: install.md is /install/
plugins: [search] (on when plugins isn't set)Pagefind after the build: afterBuild: { run: "npx -y pagefind --site dist" }. Material's own search box reads MkDocs' search/search_index.json, which isn't in ssqch yet: a page that loops over collections.all can write it
mkdocs-redirectsredirectsPlugin({ redirects }) from ssqch/redirects, or aliases on each page
git-revision-date-localizedlastModified: "git", then page.lastModified (its git_revision_date_localized); Material's blog's date.updated is date.updated in the page's data, and page.updated is git's (A post's "updated" line)
A page with no date of its ownIts file's time in ssqch, which a checkout or a save moves: dates and the order of lists change from one build to the next, and on each save ssqch serve renders the pages that show it (every page that reads collections, when the site's code sorts by dates). dateFallback: "git" gives it its last commit's date (ssqch scout counts the pages that have none)
mkdocs-macros (Jinja in Markdown)Built in: Markdown runs through Jinja first (markdownEngine: "jinja", the default)
extra_css with SasssassPlugin() from ssqch/sass
strict: truelinksPlugin() fails the build on a broken link (linksPlugin({ fail: false }) warns, as MkDocs does without strict), and strict: true for undefined template values
404.html, sitemap.xml.gz (written by MkDocs)With fromMkdocs({ templates: true }), the theme's 404.html makes /404.html; otherwise a page with permalink: /404.html. sitemapPlugin() writes sitemap.xml, and the gzipped copy is an afterBuild step (node:zlib)

Markdown extensions

Python-Markdown / PyMdownSiteSquatch
admonition: !!! note "Title" and an indented bodyfromMkdocs() reads them as they are, and writes Python-Markdown's markup (<div class="admonition note">), which Material's CSS styles. Or, in ssqch's own syntax, a container: ::: note Title ... :::. GitHub's > [!NOTE] works too.
pymdownx.details: ??? notefromMkdocs() too: <details class="note">, open with ???+. Or a container whose template writes <details> (see docs-sidebar's details container)
pymdownx.tabbed: === "Tab"fromMkdocs() reads them as they are, in the alternate style's markup. Or :::: tabs holding ::: tab Name containers (see versioned-docs)
pymdownx.superfences custom fences (mermaid)A fence-mermaid hook
pymdownx.highlight, codehilite, hl_lines="2 3"markdown: { highlight: { classes: "pygments" } }, with Pygments' class names for the theme's CSS, and {2,3} in the fence's info string. The tokens are cut by ssqch's grammars, not Pygments', and the wrapper (<div class="highlight"><pre><span></span><code>) is a fence hook's (_includes/hooks/fence.jinja, which the draft writes), so the theme's styles fit, but not byte for byte
mkautodoc, mkdocstrings (::: package.module)Not in ssqch yet: Python writes the API pages. Their ::: lines would read as ssqch's containers, so set markdown: { containers: false } (the draft does), and render the pages with the extension in Python
A Pygments lexer name ssqch doesn't have (pycon, pytb, python3, html+jinja, docker), so the fence comes out plainAn alias: markdown: { highlight: { classes: "pygments", languages: { pycon: "python", pytb: "python", python3: "python", "html+jinja": "jinja", docker: "dockerfile" } } }. A lexer of your own is a function that returns tokens, or a .sublime-syntax file (Your own highlighter)
pymdownx.snippets: --8<-- "file.py"{% include "samples/file.py" %} inside the fence
toc with permalink: truefromMkdocs() gives toc's default ids (headingIds: "python-markdown") (a repeated heading gets _1, as toc writes it); a heading hook adds the permalink. toc(page.headings) builds the table of contents.
attr_list: ## Title { #id }## Title {#id}
Links to other pages' .md filesfromMkdocs() (sourceLinks: "relative"): each goes to that page's URL, written from the page as MkDocs writes it, and images and other files are read from the Markdown file's folder too
footnotes, tablesBuilt in
def_listmarkdown: { definitionLists: true }
md_in_html (markdown="1")The markdown filter, or a container
pymdownx.emoji (:smile:)Not built in; write the emoji
pymdownx.arithmatex (generic: true) with KaTeX or MathJax in extra_javascriptmarkdown: { math: true }, and the same scripts in the theme's layout (Math with KaTeX or MathJax). A formula is <span class="math math-inline">\(...\)</span> where Arithmatex wrote class="arithmatex", so a script that looks for that class looks for math instead; KaTeX's auto-render reads the whole page. Pages that write \(...\) or \[...\] need the preprocess in the Hugo trailhead

Note

Byte for byte: a move that has to match MkDocs' output exactly needs four things from Python today: Pygments for highlighted code (codehilite's markup and tokens), mkautodoc or mkdocstrings for API pages, Material's search indexer for search/search_index.json, and Python's gzip for sitemap.xml.gz. Run them once per build in beforeBuild or afterBuild. For the rest of Python-Markdown's ways (raw HTML blocks to their closing tag, lists nested at four spaces, " as it is in text, <hr />), set markdown: { dialect: "python-markdown" }. A real-world move matched MkDocs byte for byte this way.

Pages

Front matter (title, description, and anything else) is the same YAML. MkDocs reads a page's title from its first heading when there's no title; in ssqch, give each page a title or use page.headings[0].text in the layout. A schema makes the first a rule: schemas: { docs: { files: "docs/**/*.md", fields: { title: "string" } } } fails the build for a page without one.

ssqch init --starter docs creates a docs site with a sidebar from nav.yml, a table of contents, notes, tabs and search, to move your pages into.

Checking the move

ssqch baseline "mkdocs build" --from site builds the MkDocs site in fresh copies (give it your virtual environment's mkdocs: ".venv/bin/mkdocs build"). Then build with ssqch, and ssqch diff .cache/ssqch/baseline/ref-1 site (or dist, if that's your dirs.output) lists what differs.

Only dates changed: a file whose changes are all dates or years says only dates changed (2025 -> 2026), and when every changed file is like that the summary says All N changed files differ only in dates or years. Look at where the date comes from: a build date the theme prints, or a page dated by its file's time (dateFallback: "git" gives it its last commit's date instead). Comparing builds has --ignore for what you've accepted.