Summary
Notion sync pushes content for nav-listed markdown files but does not keep the nav directory tree aligned with the Notion page hierarchy after reorganization. Users who change .nav.yml (move sections, change parents) get stale or wrong structure on Notion while local notes remain correct.
Problem
| Scenario |
Current behavior |
| Nav-only change (markdown unchanged) |
nav_changed is detected in git diff but never used |
| Change parent in nav |
Content update only; page is not reparented in Notion |
| New intermediate section |
Depends on ensure_section (see related bug for Notebook 404) |
Incremental sync only targets md_changed / assets_changed / full — structure is ignored unless content also changed.
Motivation
Nav is the source of truth for wiki layout. Notion should mirror that tree, not evolve independently.
Proposed solution
Add a structure reconciliation phase (default on, or --align-structure):
- Walk the nav tree and ensure section pages exist (create missing sections).
- For each nav-listed content page with a known Notion ID, compare nav parent vs actual Notion parent; move the page when they differ (Notion move API).
- When
nav_changed is true (even without markdown diffs), run reconciliation for the affected subtree or full tree.
- Support
--align-structure --no-content for hierarchy-only runs.
CLI sketch
mkdocs-note ns # content + align (proposed default)
mkdocs-note ns --align-structure --no-content
mkdocs-note ns --dry-run --align-structure
Optional mkdocs.yml:
notion_sync:
align_structure: true
Acceptance criteria
Out of scope (separate issues)
- Archiving orphans (
--prune)
- Git rename state migration
- Syncing nav title changes to Notion page titles
References
run_sync, collect_targets, ensure_section in mkdocs_note/utils/notion/sync.py
TreeNode.parent_key in mkdocs_note/utils/tree.py
Related
- Bug: Notebook
ensure_section parent_kind (blocks new sections under Notebook)
Summary
Notion sync pushes content for nav-listed markdown files but does not keep the nav directory tree aligned with the Notion page hierarchy after reorganization. Users who change
.nav.yml(move sections, change parents) get stale or wrong structure on Notion while local notes remain correct.Problem
nav_changedis detected in git diff but never usedupdateonly; page is not reparented in Notionensure_section(see related bug for Notebook 404)Incremental sync only targets
md_changed/assets_changed/full— structure is ignored unless content also changed.Motivation
Nav is the source of truth for wiki layout. Notion should mirror that tree, not evolve independently.
Proposed solution
Add a structure reconciliation phase (default on, or
--align-structure):nav_changedis true (even without markdown diffs), run reconciliation for the affected subtree or full tree.--align-structure --no-contentfor hierarchy-only runs.CLI sketch
mkdocs-note ns # content + align (proposed default) mkdocs-note ns --align-structure --no-content mkdocs-note ns --dry-run --align-structureOptional
mkdocs.yml:Acceptance criteria
.nav.ymlchanges alone trigger structure reconciliation.create_sectionandreparentactions.sections_created,reparented, etc.--align-structure falsepreserves current content-only behavior.Out of scope (separate issues)
--prune)References
run_sync,collect_targets,ensure_sectioninmkdocs_note/utils/notion/sync.pyTreeNode.parent_keyinmkdocs_note/utils/tree.pyRelated
ensure_sectionparent_kind (blocks new sections under Notebook)