File tree Expand file tree Collapse file tree 5 files changed +2626
-57
lines changed
Expand file tree Collapse file tree 5 files changed +2626
-57
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ pygmentsCodefencesGuessSyntax = true
2222# Localized dates requires Hugo version 0.87.0
2323localizedDates = false
2424
25+ # Mermaid
26+ [params .mermaid ]
27+ enable = true
28+
2529[markup ]
2630 [markup .goldmark ]
2731 [markup .goldmark .renderer ]
Original file line number Diff line number Diff line change 1+ +++
2+ author = " Hugo Authors"
3+ title = " Guide to Mermaid Diagrams in Hugo"
4+ date = " 2025-08-11"
5+ description = " Guide to Mermaid Diagrams in Hugo"
6+ tags = [
7+ " thumbnail" ,
8+ ]
9+ thumbnail = " images/landscape.jpg"
10+ +++
11+
12+ For displaying diagrams and charts in a Hugo project, you can leverage Mermaid.
13+
14+ If you want to use Mermaid diagrams in your site, enable mermaid support in your config file:
15+
16+
17+ ``` toml
18+ [params .mermaid ]
19+ enable = true
20+ ```
21+
22+ You can then use mermaid syntax to display your diagram:
23+
24+ ``` markdown
25+ ```mermaid
26+ sequenceDiagram
27+ Alice ->> Bob: Hello Bob, how are you?
28+ Bob-->>John: How about you John?
29+ Bob--x Alice: I am good thanks!
30+ Bob-x John: I am good thanks!
31+ Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.
32+
33+ Bob-->Alice: Checking with John...
34+ Alice->John: Yes... John, how are you?
35+ ```
36+ ```
37+
38+
39+ Which should render your diagram as:
40+
41+
42+
43+ ``` mermaid
44+ sequenceDiagram
45+ Alice ->> Bob: Hello Bob, how are you?
46+ Bob-->>John: How about you John?
47+ Bob--x Alice: I am good thanks!
48+ Bob-x John: I am good thanks!
49+ Note right of John: Bob thinks a long<br/>long time, so long<br/>that the text does<br/>not fit on a row.
50+
51+ Bob-->Alice: Checking with John...
52+ Alice->John: Yes... John, how are you?
53+ ```
Original file line number Diff line number Diff line change 11{{ if .Page.Store.Get "hasMermaid" }}
22 < script src ="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js "> </ script >
33 < script >
4- mermaid . initialize ( { startOnLoad : true } ) ;
4+ const mermaidtheme = getStoredThemeStyle ( ) === 'dark' ? 'dark' : 'base' ;
5+ mermaid . initialize ( { startOnLoad : true , theme : mermaidtheme } ) ;
56 </ script >
67{{ end }}
You can’t perform that action at this time.
0 commit comments