diff --git a/assets/scss/_code.scss b/assets/scss/_code.scss
index 7f2193a887..d491beeb45 100644
--- a/assets/scss/_code.scss
+++ b/assets/scss/_code.scss
@@ -47,4 +47,9 @@
border: 0;
}
}
+
+ pre.mermaid {
+ background-color: inherit;
+ font-size: 0;
+ }
}
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index 9a308eb761..ca06e73f25 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -18,4 +18,58 @@
{{ end }}
+
+{{ with .Site.Params.mermaid }}
+{{ if .enable }}
+
+
+
+{{ end }}
+{{ end }}
{{ partial "hooks/body-end.html" . }}
diff --git a/userguide/config.toml b/userguide/config.toml
index e5942a3dd3..82eeb508e6 100644
--- a/userguide/config.toml
+++ b/userguide/config.toml
@@ -199,3 +199,7 @@ enable = false
# url = "https://example.org/mail"
# icon = "fa fa-envelope"
# desc = "Discuss development issues around the project"
+
+[params.mermaid]
+enable = true
+theme = "default"
diff --git a/userguide/content/en/docs/Adding content/lookandfeel.md b/userguide/content/en/docs/Adding content/lookandfeel.md
index ce94413250..12fa6cca01 100644
--- a/userguide/content/en/docs/Adding content/lookandfeel.md
+++ b/userguide/content/en/docs/Adding content/lookandfeel.md
@@ -140,6 +140,57 @@ If the included Prism configuration is not sufficient for your requirements, and
* Copy the Javascript file to `static/js/prism.js`
* Copy the CSS file to `static/css/prism.css`
+## Diagrams with Mermaid
+
+[Mermaid](https://mermaid-js.github.io) is a Javascript library for rendering simple text definitions to useful diagrams in the browser. It can generate a variety of different diagram types, including flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, user journey diagrams, Gantt charts and pie charts.
+
+With Mermaid support enabled in Docsy, you can include the text definition of a Mermaid diagram inside a code block, and it will automatically be rendered by the browser as soon as the page loads.
+
+The great advantage of this is anyone who can edit the page can now edit the diagram - no more hunting for the original tools and version to make a new edit.
+
+For example, the following defines a simple flowchart:
+
+````
+```mermaid
+graph LR
+ Start --> Need{"Do I need diagrams"}
+ Need -- No --> Off["Set params.mermaid.enable = false"]
+ Need -- Yes --> HaveFun["Great! Enjoy!"]
+```
+````
+
+Automatically renders to:
+
+```mermaid
+graph LR
+ Start --> Need{"Do I need diagrams"}
+ Need -- No --> Off["Set params.mermaid.enable = false"]
+ Need -- Yes --> HaveFun["Great! Enjoy!"]
+
+```
+
+To enable/disable Mermaid, update `config.toml`:
+
+```toml
+[params.mermaid]
+enable = true
+```
+
+You can also update settings for Mermaid, such as themes, padding, etc:
+
+```toml
+[params.mermaid]
+enable = true
+theme = "neutral"
+
+[params.mermaid.flowchart]
+diagramPadding = 6
+```
+
+See the [Mermaid documentation](https://mermaid-js.github.io/mermaid/getting-started/Setup.html#mermaidapi-configuration-defaults) for a list of defaults that can be overriden.
+
+Settings can also be overridden on a per-diagram basis by making use of the `%%init%%` header at the start of the diagram definition. See the [Mermaid theming documentation](https://mermaid-js.github.io/mermaid/getting-started/theming.html#themes-at-the-local-or-current-level).
+
## Customizing templates
### Add code to head or before body end