The Graph Widget

The graph widget can be added to any page in two forms:

What graph.json looks like

graph.json contains an array of nodes and edges. Here’s a minimal example with two nodes (Backlinks and The Graph Widget) and one edge between them:

{
  "nodes": [
    {"title": "Backlinks", "type": "concept", "url": "/backlinks/"},
    {"title": "The Graph Widget", "type": "concept", "url": "/the-graph-widget/"}
  ],
  "edges": [[0, 1]]
}

Edges are pairs of node indices; [0, 1] connects the first and second nodes.

graph.json is assembled in two passes: pre-render builds the registry and backlink map from every page’s wikilinks and writes it to a side-channel file; then, at each page’s own render time, its Lua filter records that page’s real output URL to another side-channel file. Post-render joins the two and writes the final graph.json into the output directory. This late join is why a wikilink resolves to a real URL only after the whole project has rendered, not up front.

Node color

Each node’s color comes from its page’s type: frontmatter. The mapping is:

Type Color
concept #3ba29f
person #9177b6
reference #d65527
project #6b0021
experiment #c9a227
moc #8fa6d9
(none/other) #9aa0a6

Customizing the full graph widget

{{< quarto-graph-full >}} takes kwargs, all optional:

Kwarg Meaning
width Any CSS length ("600px", "80%", "50vw") applied to the widget’s container. Default: fills its container.
height Any CSS length. Default: max(420px, 65% of viewport height).
depth Show only pages within N links of root (or the current page, if root is omitted), instead of the whole project graph.
root The page to center depth on. Matched the same way a [[wikilink]] is: by title, alias, or filename stem first, falling back to a literal source path (e.g. posts/foo.qmd) if nothing matches. Ignored unless depth is also set.
expandable "true" adds a button that expands the widget to a fullscreen overlay. Default: off.
{{< quarto-graph-full width="700px" height="50vh" expandable="true" >}}

{{< quarto-graph-full root="Getting Started" depth="2" >}}

Each {{< quarto-graph-full >}} call is independent. There’s no project-wide default for any of these, unlike the sidebar mini-panel below. A root that doesn’t match any page logs a warning at render time and that particular widget renders nothing, rather than silently falling back to the whole graph.

Configuring the sidebar mini-panel

The full graph view is always opt-in, placed by the {{< quarto-graph-full >}} shortcode. The sidebar mini-panel opt-out by default, meaning unless explicitly configured off, every page will show a 1-depth graph of the current page.

Global default, in _quarto.yml:

quarto-graph:
  sidebar: true   # shorthand for {enabled: true, depth: 1}, both defaults

Or spell out either field:

quarto-graph:
  sidebar:
    enabled: true
    depth: 2

Per-page override, same key, in that page’s own frontmatter, either the bare bool or the {enabled, depth} form:

---
title: My Page
quarto-graph:
  sidebar:
    depth: 3   # this page only; enabled still inherits the project default
---

A page’s override only replaces the field(s) it actually sets: overriding just depth: keeps the project’s enabled, and vice versa.

_quarto.yml sidebar page sidebar mini-panel shows?
true (default) unset yes, depth 1
true false no
false unset no
false true yes, depth 1
{enabled: true, depth: 2} {depth: 3} yes, depth 3

If the page has no sidebar, meaning TOC is set tofalse, or using a custom layout, the sidebar minipanel will not display.

Backlinks