Links: Relative vs Absolute URL

Absolute links and relative links both play roles in creating effective websites, but understanding the differences between them is essential. External URLs are absolute links. Within your site absolute URLs are the full URL of the page a visitor is on.

Knowing the difference between absolute links and relative links typically this comes into play with files.

Example of an absolute file link: https://www.colorado.edu/compliance/sites/default/files/attached-files/6.26.17_accessibility_checklist_2017.pdf

Note: An absolute file link will include the full URL address and the file extension such as .pdf or .doc

One of the key advantages of using absolute links is that they provide a fixed and unambiguous path to a file, offering a clear indication of the exact location of the resource. 

Linking with relative URLs

The relative URL, on the other hand, does not use the full web address and only contains the location following the domain. It assumes that the link you add is on the same site and is part of the same root domain.

The relative path starts with the forward slash and leads the browser to stay within the current site. Using the node or media number is an example of a relative link.

Example of a relative link: /node/5 or /media/67

Unlike absolute links that provide the complete URL path, relative links only require the path from the current location, making them more flexible and efficient.  One key advantage of relative links is their adaptability in dynamic content scenarios. In situations where files frequently change or where the URL structure evolves, using relative links allows for seamless updates without breaking links. 

When to Use Absolute URLs vs Relative URLs

When you are linking to file on you site use the dynamic link ( /media/67) generated from the link internal content search function of the link button in the editor. This will allow you to efficiently update and replace files and not have to update the links to the files on the pages of your site. If you share this URL with others, they will always be pointed to the most current version of the file.

Example of a full URL with a relative link: https://www.colorado.edu/webcentral/node/5

If you need to share a specific file with an outside group, it may be best to email the file to them. If they do not download the file after you share the link, they may find that in time to link will not continue to work as unused files will get deleted off the site.

Note: When in doubt always use the relative link, it is less likely to break.