After making changes to Mermaid diagrams in the documentation, follow these steps to validate that they render correctly on GitHub:
- Commit and push your changes to the repository.
- Wait a few minutes for GitHub to process the changes.
- Visit the documentation page on GitHub.
- Check that each diagram renders properly instead of showing "Loading" text.
- If any diagrams are not rendering:
- Confirm the diagram uses syntax compatible with GitHub's Mermaid implementation.
- Simplify complex diagrams that may exceed GitHub's rendering capabilities.
- Remove special styling, if present.
- Ensure proper indentation and avoid special characters.
- Check for extraneous characters: Ensure lines don't have unintended trailing characters, especially after semicolons.
- Quote complex labels: Enclose node labels in double quotes (
"") if they contain HTML (like<br>), markdown, punctuation (like(),,,/), or other non-alphanumeric characters (excluding underscores). When in doubt, quote the label. (e.g.,NodeId["Label line 1<br>Label line 2"],AnotherId["My Label (New)"]). - Use specific types: Prefer explicitly listed types (like
flowchart TD) over more general ones (graph TD) if encountering issues.
You can check GitHub's current Mermaid version with this code:
info
The following diagram types are well-supported by GitHub's Mermaid implementation:
- Flowchart (using
flowchart TDorflowchart LR) - Sequence Diagram (using
sequenceDiagram) - Class Diagram (using
classDiagram) - State Diagram (using
stateDiagram-v2) - Entity Relationship Diagram (using
erDiagram) - User Journey (using
journey) - Gantt (using
gantt) - Pie Chart (using
pie) - Requirement Diagram (using
requirementDiagram)
Here's a simple test diagram that should always render correctly:
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Action 1]
B -->|No| D[Action 2]
C --> E[End]
D --> E