DEV Community

Daniel Pertu
Daniel Pertu

Posted on

Our newest hub lends eight of its nine links to an older cluster, and four of them are invisible to the link tests

Every public page on this site is a node in one TypeScript array. The sitemap, the canonicals, the breadcrumbs, the navigation and the related links are all derived from it, and 21 tests in one file assert things about that array and the graph it produces: no orphans, no self-links, every hub links to all its spokes, every spoke links up to its hub, and every link points at a page that exists.

Last night a new cluster was added with exactly one page under it. That is an awkward number for a hub, so the hub does something the other six do not: it borrows. The new trivia hub renders nine editorial links, one to its own single spoke and eight into the older question cluster, on the argument that films and music do not change at a national border and a second copy of them would only compete with the first.

That one decision put four systems into disagreement about what this page links to. Counting them is the post.

Four places a link can live

Where the link lives Feeds the rendered page Feeds the registry graph Feeds the JSON-LD Checked by a test
related array on a registry node yes yes no yes
hub-to-spokes, derived from the cluster key yes yes yes yes
a const array inside the hub's page file yes no yes no
the footer's cluster list yes counts as inbound no partly

The third row is new as of last night. It is an eight-element array of paths, declared in the page component, with a comment explaining the editorial rule behind it. It is a perfectly reasonable place to put editorial judgement. It is also outside everything that checks anything.

The numbers

The registry holds 114 nodes and produces 746 edges. For the new hub:

  • rendered on the page: 55 internal hrefs, 40 of them distinct, 9 of which are editorial links in the page's own lists
  • known to the registry graph: 6 (one spoke, five related entries that happen to overlap the borrowed list)
  • in the hub's ItemList structured data: 9
  • rendered but unknown to the graph: 4 (the film and TV set, the music set, the science and nature set, and the hard set)

The four unmodelled links are the ones that are in the page file's array and not in related. The other four borrowed links appear in both lists, which has a visible consequence: they are rendered twice on the page, once in the borrowed list and once in the related cards at the bottom. Four of nine borrowed links are duplicates on the same page, and the duplication is the artefact of the same link being held in two places by two different mechanisms.

The test suite admits this in a comment

The function that produces the graph has a doc comment I had read a dozen times before it mattered. In paraphrase: this is the graph the link tests run against, so it has to match what the components actually put on the page, and a page that renders links the registry does not know about will still pass, because nothing can stop that.

That is honest, correct, and now true in a specific way. The test that asserts every outbound link points at a real page iterates the registry's idea of the page's links, so a typo inside the page-level array would ship a 404 link straight past a green suite. All 24 content tests pass in 251 ms this morning, and four live links on our newest hub were never looked at.

To be fair to the design, the tests catch the failure that actually happens. A page-level array is read by a human when the page is written; a registry entry is read by nobody, which is why it needs assertions. The asymmetry is defensible. It is just invisible until a hub starts borrowing.

How the cluster actually gets its inbound links

One line changed in the navigation module: a cluster key was added to the array that builds the footer's Resources column. I counted the result in the saved HTML of all 117 live URLs:

Pages Links to /trivia-questions in the served HTML
110 1
4 2
3 0

The three zeroes are the legal pages, which get a compact footer. The four twos are the old question hub and the British Christmas page, which link across editorially, plus the new hub and its spoke, which link to each other. So the inbound profile of a brand new cluster is 114 footer links and 2 links written by a person: the old question hub, and the British Christmas page pointing across at the American one.

The header is more interesting, because it looks like a second source of links and is not. The header has a Resources menu, the new cluster is in it, and the menu's contents are not in the server HTML at all: the button is there, the list is rendered when you open it. Searching the served markup of the hub page for links to the cluster finds exactly one, in the footer. One line in a nav array bought 114 crawlable links and zero of them came from the navigation anybody actually clicks.

What a borrowed page knows about the hub that borrowed it

Nothing. Open the film and TV set, which is item four in the new hub's list, and its BreadcrumbList is:

Home > Questions > Film and TV
Enter fullscreen mode Exit fullscreen mode

Its visible breadcrumb says the same, its related cards point at other pages in its own cluster, and its only path back to the hub that lends it out is the footer link every page has. That is the cost of borrowing rather than copying: the link is one-directional by construction, because the borrowed page belongs to a different parent and should keep saying so.

Reciprocity across the new cluster, counting only editorial related edges: the hub lists six related pages and one of them lists it back. The spoke lists four and one of them lists it back.

The ItemList says "Quiz" eight times and the page says it zero times

One last disagreement, and my favourite, because it comes from two fields that are both correct.

The hub's ItemList structured data names its nine items from each node's title. The visible list anchors the same nine items with each node's shortLabel. Those fields exist for a reason: a <title> needs to be a complete search result, a link in a list needs to be short.

The result on a page targeting the American word:

  • JSON-LD names: "Christmas Movie Quiz Questions and Trivia", "Film and TV Quiz Questions", "Music Quiz Questions", "Hard Quiz Questions", and so on. Eight of the nine contain "Quiz".
  • Visible anchor text: "Christmas movies", "Film and TV", "Music", "Hard questions". Zero contain "Quiz".

A crawler reading the markup gets a list of nine quiz pages. A reader gets a list of nine topics. Both are accurate and they are not the same list, which is a reasonable summary of what borrowing pages across a vocabulary border does to a site.

The fix

Move the borrowed list into the registry as a field, something like borrows: string[], rendered by the hub and included by outboundLinksFor. Then one array is the source for the page, the graph, the JSON-LD and the tests, the four duplicated anchors collapse into one list, and a mistyped path fails the suite instead of shipping.

I would not move the comment that explains the editorial rule, though. That belongs next to the list, wherever the list ends up living.

What I cannot measure

Whether lending eight pages to a hub that targets a different word helps either page. The hub looks useful today, and the alternative was a hub with one link on it, and both of those are design arguments rather than measurements. What I can measure is that four systems describe this one page differently, and the ranking of how much each one is trusted is exactly backwards: the page-level array decides what readers see, and it is the only one nothing checks.

Top comments (0)