{
  "id": 22588093,
  "title": "I wrote a script to stop my internal links from rotting",
  "url": "https://urgent.news/2026/11/29/i-wrote-a-script-to-stop-my-internal-links-from-rotting",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-29T13:38:44.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/gta6status2/i-wrote-a-script-to-stop-my-internal-links-from-rotting-4dl2"
  },
  "original_language": null,
  "account": "A website consisting of 286 pages faced an issue with broken internal links. New pages were initially orphans, and outdated URLs ceased to function when URLs were modified. To tackle this problem, a script was created. Initially, each page included a \"related reading\" section as it was being written. However, after page eighty, the same six popular articles were being linked repeatedly, and many older pages had no incoming connections. The framework was straightforward: when crafting a new page, links could only point back to existing pages. Forward links were only added by editing older pages, which was not a desirable task. The script's functionality is as follows: it scans all content files, categorizes them by topic, and for each page, selects a few other pages within the same topic group. It then inserts the related-reading links into the page during the build process. Since it only operates after all pages have been identified, it can establish both forward and backward links. Consequently, every page now has at least two incoming links, and no pages remain unlinked. Additionally, a verification process was implemented, which occurs after the build. This process examines each generated page, extracts the internal hrefs, and confirms that each link is valid. This mechanism allowed the reporter to identify a previous error where the initial version was referencing the incorrect path segment, resulting in false positives. To prevent the script from feeling overly automated, minimal human input was retained. Each topic group received a predefined label, and the links were rendered as concise \"read next\" statements instead of an extensive list of options. The result appeared purposeful to readers, while the maintenance tasks remained automated. Whenever a new page is added, the entire network is automatically updated. The script runs before deployment, providing three metrics: total pages, orphaned pages, and broken internal links. If either of the last two numbers is not zero, the deployment is halted. This process takes just a second and has detected more issues than any manual review. For those managing a growing static site, it is recommended to consider internal links as generated data with an integrated validation step rather than static content.",
  "summary": "A site with 286 pages has a link problem. Every new page is an orphan until something points at it, and every redesigned URL silently breaks old links. I stopped doing this by hand a while ago. The problem with manual internal links I started by adding a \"related reading\" section to each page as I wrote it. That worked for the first twenty pages. By page eighty I was linking to the same six…",
  "summary_source": "publisher",
  "key_points": [
    "Script scans and categorizes pages by topic",
    "Inserts related-reading links during build process",
    "Verification step ensures all links are valid"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}