Draw.io
A diagram exported from Draw.io can carry its own source. Put such an export in a page as an ordinary Markdown image and the theme adds an edit button that opens it in the Draw.io editor, so a reader or a teammate can change the diagram and download the result instead of redrawing it from a screenshot. There is no fence or shortcode: the only requirement is that you tick “Include a copy of my diagram” when you export the SVG or PNG. A diagram that only needs to be looked at is an ordinary image.
Shortest form
The edit button appears once the site sets params.drawio.enable: true and
an editor address in params.drawio.drawio_server, as shown under
The editor address. Until then, every diagram is shown as a plain
image.
Write the diagram like any image. The .drawio.svg name is a convention that
helps you find the editable files; the theme does not look at the name.
A pencil button appears at the bottom right of the diagram when the pointer is over it or keyboard focus reaches it; on touch screens and in forced-colors mode it is always visible. The button opens the configured editor over the whole page. When image zoom is also on, Edit and Zoom are two separate buttons, and Edit never opens the zoom dialog.
How the copy is detected
What decides is the content of the file: an export with an embedded Draw.io copy gets the button, and any other image does not. This hand-drawn SVG uses the same syntax and attribute line as the diagram above, but it carries no copy, so it has no button:
With a caption
A Draw.io diagram is rendered by the ordinary image hook, so every
image attribute applies. Add caption for a
captioned figure; the edit button stays on the image.
As a numbered figure
Add {#id num=…} to make it a numbered figure that xref can refer to and
that appears in the list of figures:
Publishing books has the complete numbering and cross-reference rules.
SVG or PNG
Both work. A PNG export keeps the editable copy in a text chunk of the image, and the button appears the same way:

Prefer SVG for documentation: it stays sharp at any size, its labels are real text that search and screen readers can read, and its diffs are readable in review. Choose PNG for a very complex diagram or for a platform without SVG support. Hugo’s image processing works only on PNG; processing an SVG warns and keeps the original file.
What the button does
Edit hands the diagram to the editor and gives the reader a file back; nothing on the site changes.
The editor opens over the page
A full-screen dialog opens with the Draw.io editor inside it and a Close button in the reader’s language. Keyboard focus stays inside the dialog. Close it with that button, by clicking the background, or with Escape while focus is outside the editor, which handles its own keys. Focus then returns to the Edit button.
The diagram goes straight to the editor
When the editor is ready, the reader’s browser hands it the image together with its embedded copy. The diagram does not pass through your web server.
Saving downloads a new file
Save in the editor, and the browser downloads the diagram in its original
format, SVG or PNG, under the original file name. Nothing is written back to
the site: to publish the change, replace the file in content/ with the
download and commit it.
The button lets readers take a diagram away and change it; it is not an online editor for the site.
The editor address
enable: truewithoutdrawio_serverwarns and leaves editing off. The theme never picks a public service for you.- The address must be an
http(s)URL or a local path; a local path follows the deployment subpath inbaseURL. Whitespace, control characters, backslashes, protocol-relative URLs (//host/) and other schemes warn and turn editing off. - Query parameters and a fragment in the address, such as
?lang=en, are kept, and the theme adds Draw.io’s embed-mode parameters (embed=1,proto=jsonand others). - When diagrams must not leave your organization, run a self-hosted editor and point the address at it.
- The public editor
https://embed.diagrams.net/works too, but the reader’s diagram is then opened in a third-party page.
Configuration defines both keys.
Output
The diagram appears as an ordinary image in print, RSS and the page’s Markdown output; only the HTML page gets the edit button.
Parameter reference
Draw.io has no parameters of its own on the page. The attribute line is the
one from Images: caption, width, height,
link, #id, num, command and options.
Site parameters (hugo.yml):
Limits
- The edit check runs only on pages with PNG or SVG images, and it reads each distinct image address once to look for an embedded copy.
- An export made without “Include a copy of my diagram” has no copy, so it gets no button.
- Editing needs the editor to be reachable. Offline, diagrams display normally but the editor cannot load.
- Saving only downloads a file; replacing it in the repository and committing is up to you.
- An exported SVG has fixed colors that do not follow light and dark mode.
Use
nonefills and neutral gray lines and text, as the diagrams on this page do, so that the diagram reads well in both.
Related
- Images — captions, numbering, sizing and zoom in full
- PlantUML — UML diagrams; see its rendering modes and version requirements
- Mermaid — diagrams from text with no server at all
- Configuration — the full definition of
params.drawio.*