Convert a GitBook or HonKit project to mdPress format. The migrate command detects GitBook/HonKit structure, converts book.json to book.yaml, rewrites GitBook-specific template tags in Markdown files, and prints a migration report.
mdpress migrate [directory] [flags]| Argument | Required | Description |
|---|---|---|
[directory] |
No | Path to the GitBook/HonKit project. If omitted, the current directory is used. |
| Flag | Default | Description |
|---|---|---|
--dry-run |
off | Preview changes without writing any files. Useful for checking what will be modified before committing to the migration. |
--force |
off | Overwrite existing book.yaml instead of skipping. |
migrate checks for GitBook/HonKit project markers in the directory:
book.json: GitBook/HonKit configuration fileSUMMARY.md: GitBook chapter structure (already compatible with mdPress)
If neither file is found, the command fails with an error.
-
Reads
book.json(if present)- Parses JSON configuration
- Extracts title, author, language, and description
- Converts to
book.yamlformat with mdPress structure - Adds a comment header:
# Generated by mdpress migrate from book.json
-
Skips
SUMMARY.md- mdPress natively supports GitBook-style SUMMARY.md
- No conversion needed; the file is left untouched
-
Rewrites GitBook template tags in Markdown files
{% hint style="TYPE" %}...{% endhint %}→ Markdown blockquote with type prefix{% code title="..." %}...{% endcode %}→ Fenced code block (title is dropped){% tabs %}...{% endtabs %}with nested{% tab title="NAME" %}→ Level 4 headings (####) plus content
-
Walks all
.mdfiles recursively- Skips hidden directories (starting with
.),node_modules/, and_book/ - Only processes
.mdfiles with recognized GitBook tags - Writes modified files in place (unless
--dry-runis set)
- Skips hidden directories (starting with
-
Prints a migration report
- Lists created files (e.g.,
book.yaml) - Lists modified files (Markdown files with rewritten tags)
- Lists skipped items (e.g.,
SUMMARY.md) - Lists warnings (e.g., unsupported plugins)
- Lists created files (e.g.,
When --dry-run is set:
mdpress migrate --dry-run ./my-gitbookThe command prints what it would do without modifying any files. Useful for previewing the impact before committing to the migration.
The command reads book.json and warns about plugins that have no direct mdPress equivalent:
Warnings:
! GitBook plugin "disqus" has no direct mdpress equivalent — you may need to manually implement equivalent features
Known plugins that are handled natively or skipped:
highlight,search,lunr,sharing,fontsettings,theme-default
# Migrate the current directory
mdpress migrate
# Migrate a specific GitBook project
mdpress migrate ./my-gitbook
# Preview changes without writing
mdpress migrate --dry-run ./my-gitbook
# Migrate and then build
mdpress migrate ./my-gitbook
mdpress build ./my-gitbook --format pdfWhen book.json exists, the command creates book.yaml:
# Generated by `mdpress migrate` from book.json
# Review and adjust as needed.
book:
title: My Book
author: John Doe
language: en
description: A sample book
style:
theme: technical
output:
filename: output
toc: true
cover: falseMarkdown files are rewritten in place to use standard Markdown equivalents:
Before (GitBook):
{% hint style="info" %}
This is important.
{% endhint %}
{% code title="example.sh" %}
echo "Hello"
{% endcode %}After (mdPress):
> **INFO:** This is important.
echo "Hello"
- The command is best used as the first step after cloning a GitBook project.
- Always review the generated
book.yamland ensure it matches your intended metadata. - GitBook plugins that have no mdPress equivalent will generate warnings; you may need to manually implement equivalent features.
- After migration, run
mdpress validateto check the resulting structure. - Run
mdpress buildto generate the output in your preferred format.
- MIGRATION_FROM_GITBOOK.md for a step-by-step migration guide
- build for building migrated projects
- validate for checking migrated projects