It’s All Relative… Or at Least it Should Be


This is a quick lesson to those who haven’t had much for SharePoint 2010 experience. When creating links and navigation in your SharePoint sites, make sure you use Relative URL’s instead of Absolute URL’s.

First, what is the different between a Relative and Absolute URL or path?

  • Absolute Path: An Absolute Path or URL is the use of the full Path to a location or file requiring no dependency.
  • Relative Path: A Relative Path or URL points to a location or file in relation to where you currently are at.
Here are some basic examples of what this might look like.
Absolute Path
Relative Path
/directory/file.aspx
Note the difference in the URL or path above in the examples.
Why is it important to use Relative URL’s in SharePoint?
When you are linking or referring to locations within your SharePoint 2010 sites and you use an Absolute path you are essentially hard coding the link to that location. This is fine if you never end up moving or copying your work to use in a different location. Once you start copying your sites, lists, libraries, etc. you start running into a lot of manual labor to change all of your linking.
At my organization we maintain a Development and Production SharePoint 2010 Farm. Each farm is independent of each other but they match each other. Periodically we synchronize the content and configurations from one farm to the other. If we used Absolute URL’s for all of our links and navigation we would have an Absolute nightmare on our hands.
Here’s How it Works
I have two farms. PROD and DEV noted below
If I want to copy http://dev.mysite.com/sites/site.aspx from DEV to PROD and I have Absolute URL’s as my navigation when the copy is completed all my navigation in the PROD site will still point to http://dev.mysite.com/sites/site.aspx.
Instead we should configure our navigation and links to reference the Relative path to the site as /sites/site.aspx.
Now when we copy a site it will retain the path from the original site but use the correct path based on where you are at when accessing it. That means if you are in PROD and click the link, you will stay in PROD.
If you do not do this you will find you may get redirected to a different farm than you expected and you could end up editing your Production environment when you meant to edit your Development environment. It will also speed up the process of moving sites from one collection to another as you have eliminated the need to manually edit your navigation.
**There are instances in which Absolute paths are needed, but typically if referencing a site within your own SharePoint farm you will use Relative paths.**
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s