Absolute Linking Vs Relative Linking
Importance and Relevance to
Search Engine Optimization
Links can be created as absolute or relative links. Though each link may point to only one resource, there are different ways to can formulate them. Let's discuss what they are and how they are different. Also, lets discuss why you might want to choose one style over the other.
As you develop your web-site you may encounter the Absolute or Relative question. So, lets take a look at the question and try to answer it as simply as possible. This is part 4 of the series "Understanding linking for Search Engine Optimization".
Absolute Linking :
Absolute links use the full path of the resource including the transport protocol(http), the www, the sub-domain name the domain name and the name of the resource followed by any parameter in the query string .All these form part of the HREF attribute of the A(anchor) tag.
For example, <a href="http://www.NobleRiver.com/articles/Marketing-Articles.aspx"> Anchor Text here. </a>
In most cases, if you use the Absolute linking method, every resource on your web-site will have one and only one URL. Conversely, no matter where your link is located, it will always remain the same and unique. Canonicalization issues are minimized.
Relative Linking :
When using relative linking, the href attribute does not contain the domain name. The path used for the href attribute will depend on the location of the link.
If you have a resource in your web-site that needs to be linked from multiple locations on your site, every link may have a different href attribute.
As long as we are on the subject of linking, one of the best linking tools available on the market is at www.eliteseotool.com.
This is the tool I most commonly use and would recommend to you.
For example, if you are on a page(let's say Page1) that is linking to another page(Page2) which is located in the same folder, you can use the following:
<a href="Page2.html"> Page 2</a>
On the other hand if Page 2 is in a sub folder within the same folder, you have to put the relative path in the href attribute.
<a href="/subfolder/Page2.html"> Page 2</a>
If Page 2 is located in a folder above the current folder, here is how your relative link will look. Here the .. will open the folder one level up and look for the file.
<a href="../Page2.html"> Page 2</a>
Now, lets see what happens if the page is in a folder somewhere above the current folder. Actually this opens up a little bit of complexity in the whole affair.
<a href="../../Otherfolder/Page2.html"> Page 2</a>
In the example above, you need to use as many .. as the number of folders you need to traverse.
I am sure, by now you must be wondering what the benefit if any is of using relative linking!
Let's now look at the relative pros and cons of absolute and relative linking.
Absolute Linking :Pros and cons
There are actually many reasons why absolute linking is preferred:
- Canonicalization: Every resource has one single link that it uses; no matter where it is. This may be good from the viewpoint of Search Engine Optimization.
- Readability: If you are looking at a link, it helps to have the entire link at one place.
- Avoid problems in Anchor Tag: Very often, I come across problems in the anchor tag on article directories. I copy a link from the page and paste it on my browser because of problems in the formation of the Anchor Tag. Absolute links will appear as complete urls in such a case.
- Repurposing content: If you re-use your content for multiple articles or copy a link from one article to another, you need to have absolute links in them. Pages with relative links will need to be reworked before they can be submitted.
- Simpler to use: An absolute tag is always simpler to use and understand.
- Coding a tag: If you have no technical background, its better to stay with absolute linking. Though relative links look better for their brevity, coding them can be nightmarish.
- Syndication: If your content is being used by other blogs, you need any links within your material to be intact when you syndicate the content.
- Maintenance: If you are moving your page from one folder to another due to maintenance, its easier to do a blanket Find and Replace for all the links pointing to your resource.
- Better for Search Engines: There is no difference between absolute linking and relative linking as far as Search Engine Optimization is concerned. Search Engines are quite efficient when it comes to figuring out the full path for the relative links. Having said that, I still prefer to use absolute linking. Its better for us to cover all the bases and not leave it to chance.
- Over the internet, you will see that absolute linking is a way to catch scrapers who steal your content but forget to change the absolute links. When someone clicks on the links, it opens your page.
Relative Linking : Pros and cons
- Shorter paths: For the website owner, it's easier to work with shorter paths than longer ones.
- Easier coding: When there is a relatively less number of words in the URL, less effort is involved.
- Relative linking shines when you are working on a website in multiple environments. For example if you have a dev version and you are using absolute linking, you may accidentally open up the production version of the page.
- All in all, relative linking is tougher to maintain because you cannot do a blanket search and replace.
- You need to be aware of whether to use the ., ./, .., ../ etc when using relative linking.
- If you code using ASP.NET and master pages, you can have issues with relative links on the master page.
There are a few other ways you can code links that need to be mentioned here.
Runat = Server
When coding in ASP.NET, the easiest way to link is to use the "runat = server" attribute with the html anchor tag. This gives you the benfits of a relative link when coding while tacks on the domain name in the final html page.
<a href="~/Page2.aspx" runat="server" id="link5" title="title here"> </a>
The <base> tag
Add this tag to the <head> section of your html page and add the url attribute to denote where every relative link should start. < base url="http://www.website.com/" / >
You can then use a relative URL in an anchor <a href="content/articles/Page2.html" > Page 2 < /a > would resolve to the URL.
Using a variable :
In languages such as PHP and ASP.NET, you can use a variable to store the value of the domain name or wherever you want the links to start. At runtime, the links get converted to an absolute URL.
You could also use a similar construct in a config file.
Caveat: The problem with the above two methods and many others is that you need good familiarity with coding methods and technical issues.
Absolute Linking Vs Relative Linking : When to use what.
The following suggestions have arisen from a lot of experience with websites. Along with optimization benefits, I also care deeply about management and maintenance.
- Use Absolute Links when linking to an image: This will enable you to store all your images on the server and refer to them from the local machine.
- Use Relative links when linking to files: You may need to keep updating files when you are making changes to copy and other aspects of your page. Its far easier to deal with files on your local machine than ones on the server.
- Here ia another reason to link to all pages with relative links.
When you are browsing your website on the local machine while making changes, it is so much easier to go from page to page via the relative links. Once you move the files to the webserver you do not need to change them since they should still work as all file locations are relative to the root folder.