# Government link check rules Version 2026-12-04. From jwatte.com: https://jwatte.com/blog/government-link-rot-check-blog/ Rules for checking links to government sources (or any official source) on a blog, a help center or a documentation site. They come from checking 3,454 government URLs, where a plain HTTP checker flagged 32% as broken and the real figure was 2.2%. --- ## 1. Extract links exactly - Take each link target exactly as written in your source (Markdown `[text](url)`, HTML `href="..."`, bare URLs). - Do NOT strip trailing periods. Some official URLs end in one (regulation sections like `252.204-7012.`, state code sections like `1798.135.`, pages like `travel-outside-the-u.s.`). - Do NOT cut a URL at an apostrophe or parenthesis inside a Markdown link target; real file names contain them. - Deduplicate: check each URL once, keep the list of pages that cite it. ## 2. First pass: plain HTTP, polite - About 1 request per second per host. Normal browser-like User-Agent. Timeout about 20 s. - Try HEAD, and on ANY failure retry with GET. (HEAD gave 405s and even false 404s.) - Follow redirects; record the final URL. A redirect to a site's home page is suspicious: the specific page may be gone. - Cache results for about 7 days. ## 3. Classify | First-pass result | Meaning | What to do | |---|---|---| | 200 on the final URL | OK | nothing | | Redirect to a specific page | moved, still works | optionally update to the final URL | | Redirect to the home page | probably removed | verify in a browser | | 401, 403, 429, bot challenge | BLOCKED: unknown, not dead | recheck in a real browser | | 404 or 410 | maybe dead | recheck in a real browser (some sites 404 scripts only) | | TLS error | usually your trust store | recheck in a browser | | Timeout, connection reset | unknown | recheck later | | DNS: name not found | maybe dead | ask 3 resolvers (e.g. system, 1.1.1.1, 8.8.8.8) | Only two outcomes count as BROKEN: 1. **Dead DNS:** no resolver finds the name AND at least 2 of 3 report it does not exist. 2. **Browser-confirmed 404/410:** a real browser loads the URL and gets 404/410, or a page whose title or body says "not found". Everything else is OK, moved, or unknown. Never tell an editor to delete a citation because a script got a 403. ## 4. Fix a broken link In order of preference: 1. **Verified move.** Find the same resource at a new address (site search, the agency's API, a redirect from a parent page). Open it and confirm it is the SAME document: same title, same section, and the same figure or quote the page cites. Record old -> new, date, reason. 2. **Archived copy.** If the resource itself is gone, link a dated Internet Archive capture of the EXACT original URL, preferably the last capture before it died: `https://web.archive.org/web/YYYYMMDDhhmmss/https://original.example.gov/page` Open the capture and confirm it shows the cited content. 3. **Editor's decision.** A similar but different page (a newer edition, a summary instead of the full text) changes what you are citing. Do not swap it in automatically. 4. **No capture ever exists.** The URL was probably wrong when published. Find a correct source or rewrite the sentence. Change only the URL. Do not let a script edit prose. ## 5. Gate before publishing - Check only the pages changed in this release (plus a fallback window, e.g. the last 72 hours, for releases already committed). - Block the publish only for a BROKEN link that the change ADDS. Warn for links that were already broken in an edited page, so a typo fix does not block a release. - BLOCKED, ERROR and timeouts never block. - Cap the gate's run time (e.g. 4 minutes) so it can never hang a deploy. ## 6. Weekly full check - Run the full check with a real browser once a week (e.g. a scheduled CI job). - Publish the report as an artifact. The job must not push, deploy or edit anything. - Read the report for BATCHES: many links on one host breaking at once means the site changed its URL scheme. Fix the pattern once. ## 7. Keep the report safe - Some redirects end on pre-signed cloud storage URLs carrying an access key ID and a signature. Strip query strings such as `AWSAccessKeyId`, `X-Amz-Signature`, `Signature`, `sig`, `token` before writing URLs to a report. - If reports are committed to a repository, run your secret scanner on them. ## 8. Sample weekly job (GitHub Actions outline) ```yaml name: gov-links-weekly on: schedule: - cron: "0 14 * * 1" # Mondays 14:00 UTC workflow_dispatch: permissions: contents: read jobs: check: runs-on: ubuntu-latest timeout-minutes: 60 steps: - uses: actions/checkout@v4 with: persist-credentials: false - uses: actions/setup-node@v4 with: node-version: 22 - name: Check links (report only) run: node scripts/check-links.mjs --all --report reports/links.md - uses: actions/upload-artifact@v4 with: name: link-report path: reports/ retention-days: 90 ``` `scripts/check-links.mjs` is your own checker implementing sections 1 to 3 and 7. --- Informational only.