The Unbroken Chain: On Preserving Hyperlink Context with the Wget --convert-links Flag

We often speak of web archiving in grand terms: saving entire sites, preserving digital cultures, fighting against the inevitable decay of the network. But the most profound loss is often the smallest: the broken link. It’s not just the destination page that vanishes; it’s the context of the link itself, the reason it was placed there by the author, the semantic thread that connected one idea to another. When we save a page, we must save its intent to connect. This is where a simple, often-overlooked command-line flag becomes an act of profound fidelity.

Most of us who have dabbled in saving web pages are familiar with Wget, the venerable command-line tool for retrieving content. The standard recursive download, `wget -r`, does a decent job of pulling down HTML, images, and other assets. But open that saved HTML file on your local machine and hover over a link that originally pointed to another page on the same site. You’ll likely find it still points out to the live web, or worse, to a non-existent local path. The archive is a collection of isolated islands, not a preserved continent. The relational tissue is gone.

This is the precise problem the `--convert-links` flag is built to solve. Its function is elegantly simple yet transformative. After Wget has finished downloading all the files, it performs a second pass through the retrieved HTML. It analyzes every hyperlink and rewrites it. Links that point to external, un-downloaded resources are left alone. But crucially, links that point to other pages or assets *within the downloaded corpus* are converted into relative paths pointing to the local, archived versions of those files.

The practical effect is that your offline archive becomes truly navigable. Clicking a link in your saved `about.html` file will now correctly open your locally saved `projects.html` file, not attempt to find it on a server that may have disappeared years ago. You have preserved not just the nodes of the web, but the edges between them. You have maintained the original navigational logic of the site, allowing a researcher, a historian, or simply a curious reader to traverse the archived content as it was meant to be experienced.

Using it is a matter of appending it to a standard recursive command: `wget --recursive --page-requisites --convert-links https://example.com`. The magic happens silently after the download progress bars vanish. It is a small, technical gesture, but its implications are significant. It moves our work from mere collection towards true preservation of context. It ensures that the hyperlinks—the very architecture of the web—remain a functional, unbroken chain within our archives, tethering ideas together long after the original servers have fallen silent.

Notes & further reading

A few pages I came back to while writing this: