Skip to content

What is the difference between Absolute Links, Relative Links, and Node ID? and When should I use them?

When working in Drupal we recommend everyone to use relative links when possible over absolute links and node IDs. I will briefly touch upon the reason for this in the sections below:

Absolute Links

Absolute link: https://www.yoursite.ucmerced.edu/forms/documents/aFileName.txt

As you can see above absolute links directly reference the protocol (http/https), site name(yoursite.ucmerced.edu) and the actual path to the file (/forms/documents/aFileName.txt). Because of this absolute links are best used for external content where all this information is necessary and will not change. If you were to use absolute links when creating or editing your site should the site be renamed at any point such as when working on a developmental version(easily recognizable by the url format: YOURSITENAME.ucmerced.edu.672elmp01.blackmesh.com) any use of absolute links will become broken the moment they are transfered to the live version/renamed.

Node Ids

Node ID:/node/#

Similarly node IDs are a unique idenfier of a specific page on your drupal site. We only recommend using node IDs when it's necessary to reference a page and the relative link has a tendency of changing. Otherwise node IDs do not provide much needed context to those who have to interact and update your sites' navigation.

Relative Links

Relative link: /forms/documents/aFileName.txt

Relative urls/links (i.e. Human-readable links) unlike absolute urls assume you will be referencing something on your site and therefore does not require you to directly reference your site name. This becomes beneficial for the end user as regardless of what your site name is or becomes does not effect the links ability to correctly direct them to a page. Relative links also have the benefit of being able to provide context to where the link will take you and where it exists on your site.