All pages

Publish and share

Turn diagrams into things other people can open: images for your README, interactive pages for a website.

A quick image from the studio

With a diagram open (not in edit mode), the topbar's ⋯ menu has Export PNG: it downloads the canvas as you see it — current folds, active layers, your theme and any drawings — at the diagram's full size, not just the part on screen, at twice screen resolution. The canvas jumps to the full view for a moment while it renders. The zoom controls and the legend are left out. Nothing needs to be built, and no Chrome is involved.

For an image that belongs in the repo, use publish below instead: it is reproducible (every group unfolded, the light theme and the diagram's own style unless you name others, a declared legend baked in) and writes to the committed .diagrams/static/.

A web page from the studio

The same ⋯ menu has Export web page: it downloads <name>.html, the interactive page diagc publish writes, as one file you can send to anyone. The reader needs nothing but a browser: they can unfold groups, switch planes, and pick light or dark and a style.

The page is made from what is saved — the diagram, its layout file and its drawings, with every picture packed in — and opens the way a published page does: folded, on the first plane. Boxes you have moved but not saved with Save positions are not in it. If a picture cannot be read, the page is still saved without it, and the studio names what is missing.

Export

diagc publish                # everything
diagc publish shop payments  # only these, by diagram name
diagc publish --no-images    # HTML only
diagc publish --style sketch --theme dark   # the images in that look
diagc publish --single-file                 # every page whole, to send on its own

Four outputs:

Path What it is Commit?
.diagrams/html/<name>.html Interactive page — the model, its layout and every image, a few kilobytes — that loads the viewer from the folder below. No server needed. no
.diagrams/html/diagc-viewer/ The viewer the pages share: one script, one stylesheet, the fonts. Written once per run; the pages find it by relative path, so move html/ as a whole. no
.diagrams/html/index.html A gallery linking them all: one section per source folder, each card titled with its model's name. no
.diagrams/static/<name>.png Flat image of the first plane, sized to the diagram. Each further plane gets <name>.<plane>.png. yes

--single-file writes each page whole instead, viewer inside — a few megabytes each — for a page that has to travel on its own: an e-mail attachment, an air-gapped machine. The studio's Export web page always writes a whole page.

Freehand drawings (<name>.drawings.json) ship with the page and are included in the PNG; the export frame grows to fit a stroke drawn outside the boxes.

The PNG is drawn in the diagram's own style and the light theme, whatever a reader of the page picks — unless you choose for it: --style <id> draws every image of the run in that style preset, --theme dark in the dark theme. The pages are not touched by either; they open the way the next section says.

Put an image in your docs

![Shop](.diagrams/static/shop.png)

That is a normal repo path — it works on GitHub with no Pages setup.

Three things about the exported image, each of which will surprise you once:

  • Every group is unfolded. The PNG is a flat overview, not the folded resting state. A diagram that reads beautifully folded can be dense as an image. A view with hundreds of leaves can name the groups to keep folded in its layout overlay — "export": { "collapsed": ["big-group", "other-group"] } — which the image honours and the interactive page ignores. Fold rather than hide: a folded box still anchors its hidden children's edges, where a plane-hidden node drops them.
  • No layer is switched on interactively — but a plane's preset layers are active, because the view compiler unions the two. So an overlay reaches a committed image only if the exported plane presets it.
  • A declared legend is baked in. If the diagram calls m.legend(), the key travels with the image, and the capture frame grows by the panel's height so it never covers the diagram. Layers that are off are dropped rather than greyed — neither an image nor a published page offers a layer switch, so the rows that remain are plain rows rather than dead buttons. An undeclared legend — the on-demand key an activity, threat-model or ER page offers — is not: the page has the ▤ button, the image stays clean. See Add a legend.

Design a diagram intended for a README accordingly: keep it shallow, and either keep what matters unlayered or export a plane that presets the layers you want. Exporting one model as several images is a matter of declaring the plane you want first — Use planes and layers does exactly that for its three figures.

Two more, smaller:

  • A node's description never renders — only name does.
  • The image renders in the light theme regardless of your studio setting, unless --theme dark says otherwise.

When PNGs do not appear

The PNG step drives a real headless browser. If none is found you get:

No Chrome found — writing HTML only. Get one with 'npx playwright-core install chromium' (diagc finds it there), set CHROME_PATH, or use --no-images.

The quickest fix, on a laptop or a stock CI runner alike, is the one the line names:

npx playwright-core install chromium   # once; diagc finds what it installs
diagc publish

It downloads a Chromium into Playwright's own cache (~/.cache/ms-playwright on Linux, ~/Library/Caches/ms-playwright on macOS, %LOCALAPPDATA%\ms-playwright on Windows, or wherever PLAYWRIGHT_BROWSERS_PATH points), which publish searches after the system places. Or point it at any Chrome or Chromium:

CHROME_PATH=/path/to/chrome diagc publish

Checked automatically, in order: CHROME_PATH; /usr/bin/google-chrome, /usr/bin/google-chrome-stable, /usr/bin/chromium, /usr/bin/chromium-browser, /snap/bin/chromium, /Applications/Google Chrome.app/Contents/MacOS/Google Chrome; then Playwright's cache, the newest full Chromium first and its headless shell after.

Share an interactive page

.diagrams/html/<name>.html opens from disk, from a web server, from a file share — it folds and unfolds exactly like the studio, it just cannot save. Keep diagc-viewer/ beside it: the page loads the viewer from there. To send one page on its own, publish it with --single-file (or use the studio's Export web page), and it carries the viewer inside.

Pages with several planes get a plane picker at the top. <name>.png shows the first plane; each other plane has its own PNG beside it.

The page opens in the theme of the reader's system, light or dark. The ☾ / ☀ corner control switches it, and the browser remembers the choice for every published page on the same host. Switching back to the system's own theme forgets the choice, so the page follows the system again. The index page has the same switch.

To fix the theme of a page you embed on another site, add ?theme=dark or ?theme=light to its address. The page then shows no switch.

The page opens in its diagram's own style preset, and the Style picker at the top lets a reader try the others — sketch, neon, dos… — for as long as the page is open; a pick is not remembered, so the author's choice is what the next visit shows. ?style=sketch in the address fixes the style, as ?theme= fixes the theme, and hides the picker.

On a plan, ?group=1 opens the page grouped by team, and hide=ledger,ana opens it with those teams or people hidden. The page's own Group by team button and roster eyes keep the address in step, so a shared link opens the same view.

The Style picker redraws a published page as sketch, then neon

GIF: pick-a-style.gif

Press F to fit the whole diagram in the window again (the ⛶ corner control does the same), after a zoom or a fold has taken you somewhere else. Opening a group from its ▸ chip brings the open box into view by itself: the page pans to it, or zooms out when the box is larger than the window.

Unfolding a group brings it into view; F fits the whole diagram again

GIF: unfold-and-fit.gif

Presenting the page on a call? Press L (or the ◉ corner control) for a laser pointer: drag to draw a red trail that fades out after a second, so people can see what you are pointing at. It never touches the diagram, and Esc switches it off. The studio has the same control.

Publish to GitHub Pages

Pages cannot serve a dot-folder, so push the contents of .diagrams/html to a gh-pages branch:

diagc publish
npx gh-pages -d .diagrams/html

The first run creates the branch. main is never touched. Then enable Settings → Pages → Deploy from branch → gh-pages.

Or let CI deploy on every push: this repo's pages.yml builds the viewer, runs publish, and hands the result to GitHub's Pages actions (Settings → Pages → Source: GitHub Actions) — it is what serves the live examples. Two things to copy from it: ship html/ whole, diagc-viewer/ included, since every page loads the viewer from there; and the index reaches its thumbnails as ../static/<name>.png, so ship static/ beside html/ if you want them (html/ alone gives an index of titles only).

To send visitors of the index back to the repository, publish with --link https://github.com/<you>/<repo> — pages.yml does. The link sits in the index header only; diagram pages stay bare.

README images in .diagrams/static need none of this.

What to commit

.diagrams/.artifacts/
.diagrams/html/
.diagrams/diff/

Commit .diagrams/src/ and .diagrams/static/*.png. The artifacts, the HTML and the diff output are build output — diagc init adds these three lines; diagc publish regenerates the artifacts and the HTML, diagc diff the diff output.

Keeping images fresh

Nothing regenerates a committed PNG automatically. Re-run diagc publish when a diagram changes, and commit the image with the source change so the two never drift.

See also

View this page on GitHub