When to use Drupal paths instead of aliases

Dev

When to use Drupal paths instead of aliases

by Sean Corrales

One of the best features of using a CMS like Drupal is the ability to quickly and easily generate clean URLs. These clean URLs, or aliases, can be used most anywhere on your Drupal site but you should avoid using them in certain places.

Where to NOT use aliases and why

When defining your default front page, you should always use the node ID. The front page is defined on the “Site Information” page.

I recommend using the node ID for the default front page because Drupal does not check for redirects on the front page. That is, if you set your front page to a node in your site with the alias of “my-home-page”, and that alias later changes to “home-page” because of an update to the node’s title, any links to the home page will generate “page not found” errors. Using the node ID will ensure that you never have to worry about the alias of a page changing; the node ID will always remain the same.

Adding items to menus should also be done using the node ID. The easiest way to add items to a menu is to use the “Menu” section of the node edit page when adding or editing a node. For items that appear in multiple menus, you’ll have to add the page to the other menus manually.

When Drupal builds menus, it always converts the node ID paths into path aliases. Putting in node IDs ensures that the menu will always link to the correct path alias. Path redirects would keep users from encountering “Page not found” errors but your menu would still display the old aliases that you entered in the past.

Finding the node ID

Node IDs can be found easily by editing any page on your site. When you edit a page, you should see a path such as “http://www.example.com/node/1/edit“. The ID always follows directly after “node”.  All you need to enter in your menus or the default front page field is “node/1”.

More About the Author

Sean Corrales

Lead Web Developer
Internet Explorer ignoring CSS files Like most web developers, I do most of my development work in one browser (in my case, Firefox) and then do cross browser checks after ...
Creating checkout panes for Ubercart All code comes from a shipping insurance module I wrote for Ubercart. I plan to release it on ubercart.org and drupal.org after I ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072