This article was last updated on 2022-07-23, the content may be out of date.
The mermaid shortcode supports diagrams in Hugo with Mermaid library.
Mermaid is a library helping you to generate diagram and flowcharts from text, in a similar manner as Markdown.
Just insert your mermaid code in the mermaid shortcode and that’s it.
Tip
You can configure mermaid themes globally in config.toml via the params.mermaid parameter
Flowchart
Example flowchartmermaid input:
1
2
3
4
5
6
7
{{<mermaid>}}
graph LR;
A[Hard edge] -->|Link text| B(Round edge)
B --> C{Decision}
C -->|One| D[Result one]
C -->|Two| E[Result two]
{{</mermaid>}}
The rendered output looks like this:
Sequence Diagram
Example sequence diagrammermaid input:
1
2
3
4
5
6
7
8
9
10
11
12
13
{{<mermaid>}}
sequenceDiagram
participant Alice
participant Bob
Alice->>John: Hello John, how are you?
loop Healthcheck
John->John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail...
John-->Alice: Great!
John->Bob: How about you?
Bob-->John: Jolly good!
{{</mermaid>}}
The rendered output looks like this:
Gantt
Example Ganttmermaid input:
1
2
3
4
5
6
7
8
9
10
11
12
{{<mermaid>}}
gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram to mermaid
excludes weekdays 2014-01-10
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
{{</mermaid>}}
{{<mermaid>}}
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
{{</mermaid>}}
The rendered output looks like this:
User Journey
Example user journeymermaid input:
1
2
3
4
5
6
7
8
9
10
11
{{<mermaid>}}
journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
section Go home
Go downstairs: 5: Me
Sit down: 5: Me
{{</mermaid>}}