x

How to Use Relative Links in SharePoint

by Janice Uwujaren
Ryan McVay/Photodisc/Getty Images

There are two types of links used in the SharePoint environment: absolute and relative. The first step to understanding how to use relative links in SharePoint is recognizing the key differences between both types of links. An absolute link is an exact address of where an object exists or the explicit Uniform Resource Locator (URL) of that object. A relative link is an abbreviated URL based on the location of an object. Relative links in SharePoint are designated as server-relative, site-relative or folder-relative, based on whether you plan to use the server, site or folder as a base for the relative link.

Step 1

Use the file name of an object, when creating a relative link to an object within the same site. For example, if the site name is http://sitename/asite and you want to link to a file called image.jpg, the relative link for that object is image.jpg.

Step 2

Add the site name with a preceding slash to create a relative link to an object that is in a site or directory above the current site. For example, if you want to link to an object called test.html under the site http://sitename/bsite, the relative link for that object is ../bsite/test.html.

Create a link to a subdirectory within the same site by adding the subfolder or directory name without the preceding slash. For example, if you want to link to an object called project.aspx under the tasks subfolder of http://sitename/asite, the relative link is tasks/project.aspx.

Tips

  • Ideally, you would use an absolute link if you want the URL to remain static and always refer to a specific object or if the object exists in a separate domain. If an object exists in the same domain, you do not need to specify the exact URL of that object. Relative links are especially useful when creating sites where the server location may change at some point in the future. For instance, you can avoid the hassle of fixing broken links when migrating to a new version of SharePoint or changing domains.
  • There are two methods for converting links in SharePoint Designer: MakeAbs and MakeRel. The MakeAbs method converts a relative link to an absolute link. The MakeRel method converts an absolute link to a relative link. These two conversion methods work with Web, Web folder, Web file and navigation mode object types.

More Articles