EveryRole

Find broken links and dead buttons on your site

How to find broken links on a website you own: ask for each internal link once, slowly, and read the answer. Then the links a checker calls fine that aren’t.

Here is how to find broken links on a website you own: collect every link on every page, ask your server for each address once, and read the status of the answer. 404 or 410 is a broken link. 500 or above is a page that fails. Any link checker does this, and you should run one.

Then comes the part a checker can’t do. A link that answers 200 is not always a page that works, and a button that goes nowhere has no address to check at all. On our own practice app, four links on one page all answer 200. Two of them are broken.

Four kinds of answer from a link: 404 and 410 are a broken link, 500 and above is a failing page, 429 and 502 to 504 say nothing about the link, and 200 only means something answered
The first two rows are what a broken link checker finds. The last row is where it stops looking.

Two rules before you run anything.

Your own hosts first. The links that matter most are the ones inside your app: menu entries, buttons that are really links, “back to your items”. They break when you rename a route or delete a page, and they are fully in your hands. Links to other sites break too, but checking them is another job. Other servers rate-limit you, block anything that looks like a robot, and answer a checker differently than they answer a person. Check external links rarely, and expect false alarms.

Paced. A checker that fires five hundred requests in a few seconds at your production server looks exactly like an attack. Hosting providers and firewalls treat it as one, and a block can take your site down for real visitors on the same address. A couple of requests a second is enough for any small site. If the server answers 429 (too many requests) or 503, that says nothing about the link. It says slow down. Don’t report those as broken.

What the answer means

AnswerMeaningWhat to do
404, 410No such pageFix the link or restore the page
500 and aboveThe page crashesFix the page: this one is a bug, not a typo
429, 502, 503, 504Busy, overloaded or refusing your paceAsk again later, more slowly
301, 302Sent elsewhereFollow it and judge where you land
200Something answeredKeep reading

Check as each kind of user, too. A signed-out checker only sees the public pages. The links in the admin menu, or the ones a viewer gets and an editor doesn’t, are checked by nobody unless you sign in as them.

A status of 200 means the server sent a page. Three ways it lies:

The login page. Follow a link while signed out, or as the wrong kind of user, and many apps answer with a redirect to the login form, which answers 200. The checker is happy. Look at the final address: if you asked for the settings page and landed on the login page, that link didn’t work for this user.

The polite not-found. Some apps show “We couldn’t find that page” with a status of 200 (people call it a soft 404). The fix is on your side: make your not-found page answer 404. Then test it. Type an address that doesn’t exist and read the status in the browser’s network tab. Ours answers 404.

The wrong content. This is the one on our practice app. Its reports page has four export links:

The practice app's reports page: a table of three rows and four links under it, Export CSV, Download PDF, Export JSON and Export archive CSV
Four links. We asked for each one and read what came back.
LinkStatusWhat came back
Export CSV200The three rows of the table
Download PDF200A PDF
Export JSON200An error page that says “Export failed”, saved as report.json
Export archive CSV200An empty file

A link checker passes all four. A person who presses “Export JSON” gets a file their program can’t read, and the one who presses “Export archive CSV” gets nothing, with a file name that looks right.

The only way to catch these is to open what the link gave you. For a page: does it show what the link’s words promised? For a download: is it the type the button names, and is there anything in it? This is the same lesson as tests that pass while the app is broken: “it answered” is a check on the start of the action, not on its result.

Dead buttons

A dead button is a control that looks pressable and does nothing. It has no address, so no link checker will ever see it. Where they come from:

  • A link with href="#" or no href at all, waiting for a script that was removed or failed to load.
  • A button whose click handler throws an error on the first line. Look at the console while you click.
  • A button inside a form with type="button" and nothing attached, left over from a redesign.
  • A card that looks clickable (it has a hover style) and isn’t.

To find them, press them. For each button on a page, something observable should change: the address, the content of the page, or at least a request leaving the browser (the network tab shows it). If nothing changes, write it down.

That sounds slow, and it is slow on a big site. It is quick on the pages that matter. Do it for your home page, your main menu as each kind of user, and every page of the sign-up, and you have covered what a new visitor will press. The keyboard pass in our keyboard accessibility testing routine does the same job: tabbing to each control and pressing Enter finds the dead ones.

One trap: a button that is meant to do nothing right now. On our practice app a viewer’s “New item” button is disabled, on purpose. That’s fine, as long as it looks disabled and the page says why.

How often

After every deploy for your own links: routes are renamed in deploys. Weekly or less for external links, and treat that report as a to-do list. If you have a launch checklist, the link check belongs in its page section, and the “press it and look” part belongs with the journeys.

In a full run, EveryRole’s page checks include a link pass. It asks for each link it read on your app’s pages once per run, as each kind of user, from inside that user’s session, at a fixed pace. Only your app’s own addresses are asked for. A link whose words hold a never-click word (Delete, Pay) is never requested.

A 404 or 410 is reported as “A link on this page leads to a page that does not exist”, and a server error as “leads to a page that fails”. A busy or overloaded answer is not reported: there is nothing to say about the link.

EveryRole's page checks after a run of the practice app: 7 pages of 7 checked, 0 new, and "All 7 pages clean in run #4: they answered, with no failed requests, no page errors, and every field labelled"
Page checks on our practice app: clean. The two broken exports are on one of these seven pages.

Notice what that screen does and doesn’t say. All seven pages are clean, and the reports page with its two broken exports is one of them. The page checks are right about what they check. The exports are caught somewhere else: a download is a stop in a journey, and its main case is that it downloads a file of the type its button names, and the file isn’t empty. In our own test suite, “Export JSON” and “Export archive CSV” must both come out Broken, or our build fails.

That split is the point of this post. Links are checked by asking. Results are checked by looking.

Keep reading

Accessibility and phones

Keyboard accessibility testing in ten minutes

Keyboard accessibility testing needs no tool. Put the mouse away, press Tab, and check that you can reach everything, see where you are, and never get stuck.

6 min read