Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Heading Maps

Heading maps are the mechanism that allows action-translation to reliably match sections across languages. They live in the YAML frontmatter of each translated document and map English section IDs to translated headings.

The problem

When translating ## Introduction to Chinese, the heading becomes ## 介绍. But the system needs to know that these are the same section — so that when the English “Introduction” changes, the correct Chinese section gets updated.

Position-based matching (section 1 maps to section 1, etc.) works as a fallback, but breaks when sections are added, removed, or reordered.

How heading maps work

Each translated document contains a heading-map in its YAML frontmatter:

---
title: 蛛网模型
heading-map:
  overview: "概述"
  equilibrium: "均衡"
  exercises: "练习"
---

The keys are the English section IDs (the heading text lowercased and hyphenated, as MyST would generate). The values are the translated heading text as it appears in the target document.

When the action needs to match sections, it:

  1. Parses the English document to find section headings and generate IDs

  2. Looks up each ID in the heading-map to find the corresponding translated heading

  3. Uses heading-map matches first, falls back to position matching for any unmatched sections

Format rules

Example with nested headings:

English source:

## Model Description
### Assumptions
### Equilibrium Conditions
## Numerical Examples

Target heading-map:

heading-map:
  model-description: "模型描述"
  assumptions: "假设"
  equilibrium-conditions: "均衡条件"
  numerical-examples: "数值示例"

When heading maps are created

When to edit manually

You generally don’t need to edit heading maps by hand. However, manual editing is useful when:

Important: The heading-map values must exactly match the heading text in the document. If you change a heading, update both the heading text and the map entry.

Missing heading maps

If a target document has no heading-map, the action falls back to position-based matching — section 1 in English maps to section 1 in the translation. This works when both documents have the same number of sections in the same order, but is fragile.

The status CLI command reports files with missing heading maps as MISSING_HEADINGMAP.

ID generation rules

The heading-map key is generated from the English heading text:

English headingGenerated ID
## Introductionintroduction
## Model Descriptionmodel-description
## Equilibrium Conditionsequilibrium-conditions
### The Bellman Equationthe-bellman-equation
## Exercise 1.1exercise-11

Special characters are removed, spaces become hyphens, everything is lowercased.