Skip to main content

Automate Checking Bad Links On Your Site With Linkchecker

checking bad linksWhen it comes to keeping your website or your blog healthy and strong in search engine listings, regularly checking for broken or otherwise bad links on your website is a very good idea.

Not only is it good for your site’s overall standings in search listings, it’s also good for your visitors. No one wants to encounter broken links on a site – it’s a sign of a poorly cared for website.
Then again, regularly checking your site for bad links can be a tedious chore. We’ve covered a few tools here at MUO that can help you stay on top of things if you have the time, like Ann’s article on Xenu Link Sleuth, and Saikat’s article on Hyperlink Checker.
Those are good solutions, but again, they require your time. Checking for bad links takes work. A better solution would be to set up an automated script on your own server (or any computer connected to the Internet) to check your website for bad links and then issue a report with all of the results. Better yet, schedule it to run weekly or monthly, and you never have to think about the task again, until there are bad links discovered.

Setting Up Your LinkChecker Script

The tool that I want to focus on is one that we’ve listed in the MUO directory before called LinkChecker.
The reason I choose that tool is because LinkChecker provides an alternative command-line alternative to the standard GUI. In the command line, all you need to do is call the linkchecker application, followed by the URL that you want to check, as well as a assortment of parameters (which I’ll get to below).
checking bad links
In the case where everything goes well, and there are no issues, the command window will look something like this.
checking bad link on the website
There are no errors, so you’re just seeing a regular status update of link counts checked by the tool. On the other hand, if you have any bad links, you’ll see the errors echoed back in the command window as shown here.
checking bad link on the website
While this is useful only if you want to manually launch the script, what we’re trying to do here is automate this command. To do this, you need to understand some of the parameters that are available with this command mode option. You can find all of the parameters and flags at the LinkChecker help page. The ones that we are going to focus on are -0 and -f. That’s the output and the file parameters.
For example, you can issue the command, “linkchecker -r1 -ocsv -Fcsv http://www.topsecretwriters.com” to get a CSV file with all of the link check results, which shows up in the root linkchecker directory under the default file name “linkchecker-out.csv”.
checking bad link on the website
The CSC file shows a full listing of all bad links found, with the link checked in one column and the time/date the broken link was found as well as the warning error script.
finding bad links
This is a very cool thing – because now all you have to do is schedule a batch command to run that issues the above linkchecker command, and every day you’ll have an updated CSV file with a list of all bad links on your website. You can use this list to go through and fix all of the bad links.
If you’re unfamiliar with how to set up such a scheduled job, all you have to do is create a batch job that has the above command in it, name it something like “CheckLinks.bat”, and then schedule that batch job to run every week or every month. Just go to Start –>Accessories –> System Tools –> Scheduled Tasks.
finding bad links
Click on “Add Scheduled Task” to add the time/date you want it to run and just browse to your batch file when asked.
finding bad links
An even cooler solution, if you’re running your own web server, would be to run the LinkChecker command on your website, output to HTML format, and the move that HTML results page to a special page on your website that you can call up on any web browser to check out.
You can have the LinkChecker tool output to HTML by issuing the following command:
“linkchecker -r1 -ohtml -Fhtml/badlinks.html http://www.topsecretwriters.com”
What this does is outputs the results to an HTML file on the local linkchecker path. You’ll want to add a line to your batch file to move that HTML file to the file path where your public HTML files are stored. Just add:
“MOVE badlinks.html d:/web-server/xampp/htdocs/badlinks/”
This way, you’ll have a web directory on your website /badlinks/ where you can call up the badlinks.html page. This is what the results look like in HTML format.
checking bad links
Using this approach, you never have to even log into the server or computer where the link check script is running. You can just check your special page and deal with the errors that you find there.
Keeping on top of bad links on your site is more important than most people realize. It also happens more often than you might think, as many of the web pages you might have linked to in that article a few years ago went out of service, leaving all of your visitors out of luck when they try to follow your link to that page.
So, give the command-line option of LinkChecker a shot and see if it lets you improve your website link quality without taking up all of your valuable time. Did you take the approach above, or did you try some other technique? Share your own experiences with the script in the comments section below.

Popular posts from this blog

Samsung Galaxy S5 Review and Giveaway

Few smartphones are as aggressively marketed as Samsung’s Galaxy S5. The S5 can no longer be considered brand-new — but it  is  Samsung’s flagship, at least for the next few months. With a gorgeous screen, a capable camera, a waterproof build, and a user-replaceable battery, the Galaxy S5 has a lot to offer… at least on paper. Let’s find out how good it really is. What Makes This Review Different There are about a million Galaxy S5 reviews out there. Why should you read this one? Two keys points make our review different: We bought our own device . Unlike many tech blogs, we don’t use a review unit Samsung gave us. We went out to the store and bought one, just like you would. This means everything you read here is truly impartial – we owe Samsung nothing. We used it for more than a month . Some sites rush to be the first to publish a review on a new device. That’s not how we do things. I used the Galaxy S5 as my main (and only) Android phone for nearly two months,...

ASUS VivoBook X202E Windows 8 Touchscreen Laptop Review And Giveaway

It wasn’t very long ago when prices of touchscreen Windows 8 laptops soared beyond $1000. Thankfully, those days are behind us, and portable computers can easily be purchased – touchscreen and all – for under $500. That’s precisely the demographic in which the ASUS VivoBook X202E falls. When compared to a high-end laptop, its specifications might seem modest, but for laptop buyers just looking for a way to browse the web, watch videos, use basic apps, and not spend too much money, something in this budget is perfectly suitable. The question is, of course, how does the ASUS VivoBook X202E compare to others on the market, and is it the one which you should be spending your hard-earned money on? Well, you’re just going to have to keep reading to find out. Best of all, we are giving away an ASUS VivoBook X202E to one lucky winner. Keep reading for your chance to take home this Windows 8 touchscreen laptop! Introducing the ASUS VivoBook X202E Laptop The ASUS VivoBook X202...

Samsung Galaxy Note 3 N9000 Review and Giveaway

When it comes to massive phones, nothing is more iconic than the Samsung Galaxy Note. It has gained popularity not only due to its size, but its additional features such as a stylus and a larger battery make it a more useful phone. Samsung released the third generation of the Galaxy Note in October, updating the phablet with a larger screen and improved hardware. Read through our review, then join the giveaway to win the  Samsung Galaxy Note 3 ! Competitors Of course, other Android competitors haven’t let the $640  Galaxy Note 3  be the only player in the phablet market. There are others such as the  Sony Xperia Z Ultra , the Samsung Galaxy Mega , and the other more common phones that are reaching 5″ screens such as the  Samsung Galaxy S4 , the  HTC One , and the  Nexus 5 . Unlike the normal-sized top contenders, the Galaxy Note 3 has a bigger screen and larger battery. It also offers specific features (surrounding the S Pen stylus) th...