Detect Drupal Broken Links
I was looking in my Google analytics reports and see that I have some broken links (404 pages) in my content. Although you can track these with Analytics or other web reporting tools, there are a number of modules that can be used to help minimize and detect Drupal broken links:
- Broken Anchors (version 6 only)- Checks for broken links within your node body and comment text. Runs via cron.
- Links Checker (version 6 is dev only) - Checks for broken links within node text including CCK fields, comments, blocks, web links, etc. Will check on regular intervals (via cron) and notify you if there are broken links.
- Link Node (versions 5 & 6) - Although it doesn't check for broken links, it will help ensure that your internal link formatting is correct. You can use [node:NNN] and it will use a filter to replace with the correct href.
- Path Filter (versions 4,5 & 6) - Similar to Link Node module except you cannot specify title. You can write links like "http://www.kristen.org/content/kitchen-and-living-room".
I'm going to install all four to test them out though you don't need both Broken Anchors and Links Checker or both Link Node and Path Filter at the same time. I'm going to put two broken links on this page for checking:
- Download the tar files from the module pages above
- Untar tar files and place directories in /sites/all/modules or equivalent.
- Go to /admin/build/modules and turn on modules
- Broken Anchors - Configure broken anchors settings at /admin/settings/broken_anchor. I kept the defaults except for setting the timeout to 60 seconds since Drupal on GoDaddy is slow. Cron or poormanscron will need to be configured, or you can hit your cron.php page directly to get your crons to run. Once the cron has run, you can see your broken links in the admin reports at /admin/reports/broken_anchor. See example below.
- Link Checker - Configure at /admin/settings/linkchecker. After cron has been run, you can view the report at /admin/reports/linkchecker. See example below.
- Link Node - Add it to existing filters by configuring the ones you are using at /admin/settings/filters, or create a new filter with it at /admin/settings/filters/add. If adding a new filter, check Link Node Filter checkbox and any other desired filters and save. This will create a new filter that can be used for your nodes. To make this the default, select the new filter at /admin/settings/filters and save. For old nodes, if you want to use the new filter, you will have to switch your filter ("Input Format") over manually.
- Path Filter - Same configuration as Link Node.
Example Drupal Broken Links Report:
Example Drupal Link Checker Report:
I have turned on the Node Link filter for this node and will do three examples:
- Link to this node without a title: Detect Drupal Broken Links
- Link to this node with a title, rel, and target: link to this node
- Link to a non-existent node with title,rel, and target:
As you can see, the node link to the non-existent node doesn't actually result in an href, so we don't have a broken link, though do know it needs fixing.
I have turned on the Path Filter for this node and will do two examples:
- Link to this node: "http://www.kristen.org/content/detect-drupal-broken-links"
- Link to a non-existent node: "http://www.kristen.org/node/99999"
As you can see, it still shows the non-existent node link.
Summary: After using these four modules, I recommend Link Checker and Link Node to help with detecting and removing your broken links in Drupal (404 pages).
This is a featured content block that has been configured to show blog nodes with terms SEO or Drupal SEO by the author kristen. It shows random list of 20 results in the block and 30 results on the more page.