When you are launching a new website, you need to be sure that you find and fix as many broken links as possible before your visitors find them. The best way to deal with these broken links is with a two-phased approach – one phase before you launch and the second immediately after.
You are probably building out the new website in a development or staging environment. Let’s say that the final site will be replacing an existing site at www.domain.com and you’re building out a staging site at staging.domain.com for final review and testing before launch.
In order to run a broken link check, you’ll need a broken link scanner. There are 2 tools that I’ve used in the past and worked well. We will need to use a link scanner running on your computer (rather than a hosted solution) in order to correctly detect broken links.
Xenu Link Sleuth is a good tool with a very basic UI.
For Mac OS
Integrity is similar in that it has a basic UI and gets the job done.
It’s likely that your new, staged site will have links back to the currently live www.domain.com site. If you just run a regular broken link scan now on the staged site, you won’t detect these links and there is a good chance that they will break when the new site launches. In order to get around this, you need to edit your hosts file so that you direct any requests for www.domain.com to 0.0.0.0:
This will cause any existing links you have that point to the live site at www.domain.com to be broken and they’ll show up in your broken link report. Simply run a broken link scan, fix broken links, and scan again until you’ve fixed all the broken links.
Now that you’ve launched your new site, you need to perform a similar check to be sure that you don’t have any stale staging links on your site. Once again, edit your hosts file (be sure you remove the old www.domain.com entry) and add an entry to direct any requests for staging.domain.com to 0.0.0.0:
This will cause any links on your live site that point at your staging site to show up as broken so you can find and fix them. Run a series of broken link scans again and fix broken links until you’ve got everything fixed up.
Bonus: How to Fix
When you fix links – either on staging in Pre-Launch or on production in Post-Launch – there are two ways to do it. In either case, you will need to change a fully-qualified URL to a root-relative URL so that the link “stays” on the current domain.
Change the URL
If a given broken link only has a limited number of pages that point to it, your best bet is to simply change the URL to point to the correct page on your new site.
Redirect and Change the URL
If you suspect (or know) that a given link will appear on other sites that you have no control over, you need to put in a 301 redirect as well as change the URL on your site. Whenever possible, you should change URLs that you have control over rather than relying on redirects because each redirect slows down a user’s experience a little bit.
Once you’ve launched and fixed everything you can find, you need to continue to monitor the site and Handle 404’s Gracefully.