Drawing a Map of My Own Blog
Build an interactive map of your whole Docusaurus corpus — every article as a bubble wearing the site's mascot, sized by how many other posts link to it, positioned by a force-directed layout that runs at build time in Node so the browser never ships d3-force. Includes the plugin, the canvas component, and the plain-list fallback that keeps the page usable with JavaScript disabled.
This article is part of the Creating Docusaurus components series:
- Change how Docusaurus will create img tags
- Overrides the generation of img tags with Docusaurus
- Organize Your Docusaurus Content with a Custom Series Component
- Providing a go to the top button in Docusaurus posts
- Creating a search&replace plugin for Docusaurus
- A component for showing code snippets in a Docusaurus blog
- A Docusaurus component that alerts readers the article is over a year old
- Showing the changelog of your post
- Inject ASCII Art in any HTML pages rendered by Docusaurus
- Best Practice - Customizing the Docusaurus RSS Feed for Full Content & Images
- Running some checks on your Docusaurus images
- Tags management in Docusaurus
- Automating TL;DR Summaries with Gemini AI
- Introducing the ProjectSetup Component - A Standardized Way to Share Project Structures
- How to indicate AI-assisted content in a Docusaurus blog
- Bring Your CLI Tutorials to Life with a Typewriter Terminal
- Meerkat Mischief: Sprinkling Easter Eggs Across my Blog
- AI-Powered Code Tooltips in Docusaurus — Explain Like I'm Five
- Adding Reader Reactions to Your Docusaurus Blog
- Your Blog Is Unreadable to an AI. Here Is the Fix.
- Shake Your Phone, Startle the Meerkat
- Add a "Copy as Markdown" Button to Your Docusaurus Blog
- Ask My Blog: Turning 259 Articles Into 2,160 Searchable Questions
- The Third Door: A Floating Chat Bubble, and the Feature Nobody Could Find
- Drawing a Map of My Own Blog
- Let Readers Flag Issues — A Multi-Type Feedback Widget for Docusaurus

After 262 articles I could no longer answer simple questions about my own blog: which posts are hubs that everything links to, and which ones sit alone in a corner. So I built a /map page — a force-directed graph of the whole corpus, where each article is a dot sized by its in-degree and connected by three kinds of edge (real inline links, series neighbors, shared tags). The trick that makes it cheap: the layout runs once, in Node, at build time, so the browser receives final (x, y) coordinates and never loads a physics engine.
I publish twice a week, on Mondays and Thursdays, and I have been doing it for a while. Somewhere around post number 150 I stopped being able to answer questions I should have known by heart: is that fzf article actually linked from anywhere? Which post is the one everything else points back to? Did the whole Quarto series end up isolated from the rest of the blog?
I had the data — every article's frontmatter, every inline link — but no way to look at it. A list of 262 rows is not a way to look at anything.
So I built /map — a page that draws the blog as a graph. Here is how it works and how to build one.
What the Map Page Shows You
Every published article is a bubble. The bigger it is, the more other articles link to it. Lines connect posts that are genuinely related — hover one and everything that is not its direct neighbor dims away:
┌─ Blog Map ──────────────────────────────────────────────────────────────────┐
│ │
│ Filter by topic [ Top 120 most-linked articles ▾ ] │
│ 262 articles · 25 series · 680 internal links │
│ │
│ Running Docusaurus with Docker │
│ · · ● │
│ · ╲ │ ╱ · ╱ ╲ │
│ ·──── (◉) ────· ● ●───────● Docker-out-of-Docker │
│ · ╱ │ ╲ · ╲ ╱ │
│ · · ● │
│ 🦫 │
│ (drawn bigger than its size: │
│ nothing links to this one yet)│
│ │
│ ▸ View as list instead │
└─────────────────────────────────────────────────────────────────────────────┘
Three things worth doing on that page:
- Filter by topic using the dropdown to narrow the graph to one
mainTag. The articles that share the tag but link to nothing around them stay visible — that is exactly the kind of orphan you would otherwise never notice. - Hover a node to see its title and highlight its direct connections. A cluster that looks dense from a distance often turns out to be two or three hubs with a lot of satellites that only link inward.
- Switch to list at the bottom if you prefer prose over canvas, or if you have JavaScript disabled: every article is still there, grouped by series, fully indexed.
Why Computing the Layout at Build Time Changes Everything
A force-directed graph is normally a browser thing: you ship a physics library, drop the nodes in, and watch them settle over a few seconds. That approach fails three requirements I actually cared about, and moving the simulation into Node fixes all three at once.
- The page has to work with JavaScript disabled. If the positions are already final in the HTML payload, the only thing JavaScript adds is the drawing — so the no-JS path can fall back to a plain, server-rendered, fully indexable list of every article instead of an empty box.
- Nothing may animate on its own. There is no
prefers-reduced-motionbranch to write, because there is no motion to suppress: the graph is already at rest the instant it appears. d3-forcenever reaches the reader. It stays a build-time dependency. The browser gets numbers, not a solver.- The same build produces the same map. Node order is sorted before the simulation starts, and
d3-forceplaces nodes from their array index rather than fromMath.random(), so a rebuild with no content change reproduces the exact same picture.
The cost of all that is one extra second in yarn build. It is the best trade I have made on this blog.
Building It
Two pieces: a plugin that computes the graph, and a component that draws it.
The plugin
It reads the corpus through the same loader my tag tooling already uses, builds the edges, colors each node, runs 300 simulation ticks, and hands the result to setGlobalData:
Running it standalone shows what the payload looks like:
$ node --input-type=module -e "
import('./plugins/blog-graph-plugin/index.mjs').then(async m => {
const graph = await m.default().loadContent();
const byType = {};
for (const edge of graph.edges) byType[edge.type] = (byType[edge.type] ?? 0) + 1;
console.log('nodes ', graph.nodes.length);
console.log('edges ', graph.edges.length, byType);
console.log('meta ', graph.meta);
console.log('payload', JSON.stringify(graph).length, 'bytes');
});"
nodes 262
edges 1026 { link: 680, series: 144, tag: 202 }
meta { articleCount: 262, seriesCount: 25, linkCount: 680 }
payload 183292 bytes
262 nodes, 1026 edges, 179 KB of JSON — computed once at build time, never touched again by the browser.
One decision in there is worth pulling out: the node colors are not a new palette. A post that belongs to a series reuses that series' own accent color from src/data/series.js — the same one the series page themes its hero with. A post without a series falls back to the accent color automatically extracted from its banner image. Only a post with neither gets a neutral gray. The map therefore looks like the rest of the site for free, and a reader who already recognizes "the blue one is the Quarto series" recognizes it here too.
The component
BlogGraph reads that global data, draws it on a <canvas>, and swaps itself out for a plain list below 768px:
Need help here? Click the "Help" button above for setup instructions.
Canvas, not SVG, and that is not a stylistic preference: 262 nodes plus a thousand edges as DOM elements makes every hover a layout recalculation over a thousand nodes. On a canvas, a hover is one full redraw of a few hundred shapes, which is nothing.
Register the plugin in docusaurus.config.js and give it a page:
plugins: [
"./plugins/blog-graph-plugin/index.mjs",
// ...
],
---
title: "Blog Map"
description: "An interactive map of the whole blog."
hide_table_of_contents: true
---
import BlogGraph from "@site/src/components/BlogGraph";
<BlogGraph />
The Three Kinds of Connection
An edge means "these two posts are related", but relatedness comes in strengths, and mixing them at equal weight produces a hairball. My corpus emits three types, each with its own pull on the layout:
| Type | What it means | Count | Layout pull |
|---|---|---|---|
link | One post's prose genuinely links to another | 680 | Strongest — distance 55, strength 0.85 |
series | Two consecutive posts (by date) in the same series | 144 | Medium — distance 70, strength 0.5 |
tag | Two posts sharing several tags | 202 | Weakest — distance 110, scaled by weight |
The tag row is where the interesting failure lives. At this corpus size almost every pair of posts shares at least one tag — connecting them all would connect everything to everything and destroy both the layout and the picture. Raising the bar to two shared tags still leaves 1,355 pairs, of which 1,153 are the weakest possible kind:
shared tags: 2 3 4 5
pairs: 1153 159 40 3
So the plugin does two different things with that set. The layout uses every pair down to two shared tags, because that weak spatial pull is exactly what clusters "all my Docker posts" together. The payload ships only pairs with three or more, because nothing ever draws the rest — shipping the weight-2 majority would have tripled the JSON for invisible lines. Same data, two thresholds, one for the physics and one for the wire.
Under the Hood (skip this if you just want the map)
Four problems that were not obvious until the page was actually on screen.
A two-node filter got a giant, empty canvas
Pick a niche topic from the filter and you might get three articles. The canvas was still sized for 120. My first fix was to size it from the aspect ratio of the visible nodes' bounding box — which failed, because two articles sharing a mainTag do not have to sit near each other in the shared, whole-corpus layout. Two nodes at opposite ends produce an extreme ratio that clamps straight back to the maximum height.
The second signal, node count relative to the default view, catches that case but would squash a genuinely tall, tight cluster. So computeCanvasHeight() computes both and keeps whichever is smaller. Neither blind spot can produce an oversized canvas on its own:
const ratio = contentAspectRatio(nodes) ?? maxRatio;
const aspectHeight = clamp(Math.round(containerWidth * ratio) + padding);
const density = Math.min(nodes.length / defaultTopN, 1);
const densityHeight = clamp(
Math.round(minHeight + (maxHeight - minHeight) * Math.sqrt(density)),
);
return Math.min(aspectHeight, densityHeight);
Labels stacking on top of each other
Drawing 262 titles is unreadable, so only the eight most-connected visible nodes keep a permanent label, plus the hovered node and its direct neighbors. Even that stacks when a filtered topic is crowded. selectNonOverlappingLabels() walks the candidates in priority order — hovered node first, then neighbors, then hubs — measures each one with ctx.measureText() and drops any label whose box would intersect one already placed. Lower-priority labels lose; the hovered one always wins.
Canvas cannot hear a theme change
The node and edge colors are read from the site's own CSS variables so nothing is hardcoded — but a canvas is a bitmap, and toggling dark mode repaints nothing. The fix is a MutationObserver on <html>'s data-theme attribute that bumps a counter, which is in the redraw effect's dependency array:
useEffect(() => {
const observer = new MutationObserver(() => setThemeVersion((v) => v + 1));
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ["data-theme"],
});
return () => observer.disconnect();
}, []);
The meerkats
This blog has a mascot — it hides in the page source, rides the scroll-to-top button, and shows up on the 404 page. On the map it is not a garnish on a few nodes: every bubble is a meerkat, wearing the sticker its mainTag earned it. PHP articles hold a small purple elephant, Bash articles wear a hoodie, code-quality comes with a green checkmark. Around thirty tags have an explicit sticker and the rest draw one deterministically from whatever is left, so a topic always looks the same and its articles read as a family across the canvas.
What makes this work is the images, not the code: they are square, face-centered portraits. The full-body poses I started with lost their head to a 20px circular crop, so they had to be picked and cropped one by one; a centered portrait survives a plain "cover" draw with no per-image tuning.
Two rules keep it from turning into mush:
- a sticker needs room. Below a 12px diameter the ring eats a third of the image and a flat colored dot says more — so that is what those nodes keep.
- an orphan is drawn bigger. A node with zero visible connections sits at the minimum radius, which is exactly under that threshold. It gets a floor of 13px instead, so the one article nothing links to is the one you cannot miss.
The ring around each bubble keeps the article's own accent color, so nothing of the series/tag signal is lost to the illustration.
Conclusion
The map did exactly what I hoped: five minutes after it first rendered, I had a list of posts that nothing linked to, and I could see that one series had drifted away from everything else. That is a maintenance tool disguised as a pretty picture.
The part worth stealing, though, is not the graph — it is where the work happens. Every hard requirement on that page (no JavaScript, no motion, indexable, small payload) dissolved the moment the simulation moved from the browser to loadContent(). Docusaurus plugins run in Node with the whole corpus in hand and a build step nobody is waiting on; that is a lot of room to compute things properly, once, instead of asking every visitor's laptop to do it again.
Next time you are about to reach for a client-side library, check whether the answer it computes could have been a constant in your build output.
This article is part of the Creating Docusaurus components series:
- Change how Docusaurus will create img tags
- Overrides the generation of img tags with Docusaurus
- Organize Your Docusaurus Content with a Custom Series Component
- Providing a go to the top button in Docusaurus posts
- Creating a search&replace plugin for Docusaurus
- A component for showing code snippets in a Docusaurus blog
- A Docusaurus component that alerts readers the article is over a year old
- Showing the changelog of your post
- Inject ASCII Art in any HTML pages rendered by Docusaurus
- Best Practice - Customizing the Docusaurus RSS Feed for Full Content & Images
- Running some checks on your Docusaurus images
- Tags management in Docusaurus
- Automating TL;DR Summaries with Gemini AI
- Introducing the ProjectSetup Component - A Standardized Way to Share Project Structures
- How to indicate AI-assisted content in a Docusaurus blog
- Bring Your CLI Tutorials to Life with a Typewriter Terminal
- Meerkat Mischief: Sprinkling Easter Eggs Across my Blog
- AI-Powered Code Tooltips in Docusaurus — Explain Like I'm Five
- Adding Reader Reactions to Your Docusaurus Blog
- Your Blog Is Unreadable to an AI. Here Is the Fix.
- Shake Your Phone, Startle the Meerkat
- Add a "Copy as Markdown" Button to Your Docusaurus Blog
- Ask My Blog: Turning 259 Articles Into 2,160 Searchable Questions
- The Third Door: A Floating Chat Bubble, and the Feature Nobody Could Find
- Drawing a Map of My Own Blog
- Let Readers Flag Issues — A Multi-Type Feedback Widget for Docusaurus






