Drupal Editing: Keeping Links Functional

December 21, 2013

When editing a web page and adding a link, what happens when the target URL changes? Your links breaks. To some extent you can use the Internal Links and Link Checker modules (see our earlier post, “Drupal link tools for improved editorial workflow and SEO”). Those are handy for external links especially. But what about linking to Drupal nodes? The ideal setup would be to use only internal links, e.g. “node/123” and never link to aliases, such as “about-us” or “/about-us”. The reason being that if you linked to your About page using “about-us” or “/about-us” and later on you decide to change its alias to “about”, your link to this page will break. You can use Link Checker to track this down, but it would be even better to not have this issue arise in the first place. You can avoid this by using only internal links. You can build this into your editing workflow using the following combination of modules:

  • CKEditor – https://drupal.org/project/ckeditor
  • CKEditor Link – https://drupal.org/project/ckeditor_link. Make sure to edit the CKEditor settings AND your text format(s) to enable the CKEditor Link plugin. Otherwise your links may still get displayed as “node/123” even if you selected your path using the CKEditor Link too when editing the page.
  • Pathauto – https://drupal.org/project/pathauto – creates automatic paths based on the node title. Can also be configured to set custom paths based on the content type, and other more advanced options (using tokens). These are called Patterns. In Drupal 7 see admin/config/search/path/patterns.
  • Redirect – https://drupal.org/project/redirect – handles automatic redirection, for example when you change a node’s alias from “about-us” to “about”. Then then old alias “about-us” will redirect to “about”.
  • Global Redirect – https://drupal.org/project/globalredirect – redirects any node/123 style paths to their corresponding aliases, if any exist.