PlantUML
plantuml fence writes sequence, class, component, activity and use-case diagrams; rendering requires a PlantUML server you configure yourself.A plantuml fence holds PlantUML source. The browser compresses and encodes it,
appends it to the URL of a PlantUML server, and gets an SVG back. It suits
sequence, class, component, activity and use-case diagrams that need the full
expressiveness of UML. Rendering depends on that server: the theme ships no
default endpoint, and enable: true without svg_image_url fails the build.
With no server available, use Mermaid instead.
PlantUML has to reach a server you run, and this site assumes no endpoint on
the reader’s behalf. In the current theme version the plantuml fence also
double-escapes <, >, & and ", so source with arrows or quotes comes
back from the endpoint as a Syntax Error? image (see Limits).
Every snippet below is correct PlantUML in itself.
The encoded diagram source is sent to the endpoint you configure. Never put passwords, internal hostnames or customer names in a PlantUML fence. Internal sites should run their own endpoint, or use a pre-rendered image.
Shortest form
Sequence diagrams are the most common kind: participant declares a
participant, -> is a synchronous message, --> a return.
That draws four lanes and four messages: the reader opens the page, the browser requests the endpoint with the encoded source, the endpoint returns SVG, and the runtime swaps the fence for an image.
Class diagrams
class lists members and "1" -- "0..*" gives a relationship its cardinality —
the usual way to explain a data model.
Three boxes with their fields and two annotated connectors: one publication can serve many subscriptions, and every subscription binds one replication slot.
Component diagrams
package groups deployment units, [component] is a box, and --> is the
direction of a dependency.
Two dashed boxes with three components each, and five labelled arrows tracing the collection path.
Activity diagrams
start / stop with if … then … else … endif draws a branching procedure.
This kind contains no arrow characters, so it is the one kind that renders
correctly in the current version.
One vertical flow line, two diamonds each branching yes / no, four end points.
Use-case diagrams
actor is a stick figure, (use case) an ellipse, and rectangle draws the
system boundary — a good fit for a “who is this for” section.
Three figures on the left, one box with seven ellipses on the right, and connectors saying who can do what.
Colours in dark mode
The server knows nothing about the site’s colour scheme, so the SVG comes back
on a fixed white ground. skinparam backgroundColor transparent removes it and
the diagram sits on the page background. With neutral lines and text it reads in
both modes.
PlantUML’s !theme directive (!theme plain, for instance) also works. Themes
come from the server, so a self-hosted endpoint has to have them installed.
The rendering server
The fence itself has no switch; whether it renders depends on the site configuration:
enable: truewithoutsvg_image_urlfails the build withparams.plantuml.enable requires an explicit params.plantuml.svg_image_url. The theme does not pick a public service for the site.- To self-host, the official image
plantuml/plantuml-serverworks; pointsvg_image_urlat its/svg/path and keep the trailing slash — the encoded source is appended to it. - The endpoint’s CORS policy and the site’s CSP
img-src(plusconnect-srcwhensvg: true) must both allow it; use an absolute URL on a subpath deployment.
These keys are defined in Configuration.
Output
| Output | Shape |
|---|---|
| HTML | The source is emitted as <pre><code class="language-plantuml">; once enabled, the runtime replaces it with an <img> (with svg: true, an <svg data-src>) |
| Same as HTML: the print view loads the runtime and requests the endpoint too | |
| Markdown | The plantuml fence and its source, kept as written |
| RSS | The fence source only — subscribers see text |
When the feature is off, or the runtime has not loaded, what stays on the page is a readable source block, never a broken-image icon.
Parameter reference
Fence attributes: none. A plantuml fence reads no attribute line and does not
go through OINK’s code-block shell, so title, copy and the line-number
options from Code blocks have no effect here.
Site parameters (hugo.yml):
The theme reads those three keys and nothing else.
Limits
<,>,&and"are double-escaped: the current theme version escapes the fence content once too often, leaving literal-->and"in the page and returning aSyntax Error?image from the endpoint. Diagrams with arrows (sequence, component, use case, state) therefore do not render today; activity diagrams, which contain none of those characters, do. Until it is fixed, use Mermaid or a pre-rendered image.- A server is mandatory: the theme provides no default endpoint and assumes none.
- Diagram source leaves the browser: keep anything confidential out of a PlantUML fence.
- No colour-scheme awareness: the server does not know the reader’s mode, so
skinparamis the only lever. - No numbering, no zoom: the
<img>the runtime inserts does not pass through the image render hook, so{#id num=}and image zoom do not apply.
Related
- Mermaid — no server, follows the colour scheme, the everyday choice
- Draw.io — the other integration that needs a server of your own
- Images — pre-rendered SVG: numberable, zoomable, no external dependency
- Configuration — the full definition of
params.plantuml.*