The way that you structure your URL is absolutely essential to your site. It is the address to your site and its subpages. It’s the way Google, Bing, and other search engines land on your site. No matter what, you do not want any redundant URLs or links that are broken on your website.
You have two basic choices when it comes to the selection of URLs - absolute URL and relative URL. If you choose the wrong type, it will not only make the site difficult for search engines to crawl but also affect your SEO strategy.
Absolute URL requires you to place the entire address on the page that you link to. An example of an absolute URL would look like this:
<a href = http://www.example.com/xyz.html>
The relative URL, on the other hand, does not use the full address. It assumes that the page you type in is on the same site. An example of a relative URL would look like this:
<a href = "/xyz.html">
Why Choose Relative URL?
- Quicker Coding
Large websites are made much easier to code when you shorten your URL into a relative format.
- Staging Environment
If you are using a content management system that has staging environment with its own unique domain like WordPress or SharePoint, then your entire website is replicated on that staging domain. The relative format allows the same website to exist on staging and production domain, or the live accessible version of your website, without having to go back in and recode all of the URLs. This not only makes coding easier for a web developer but also serves as a time saver.
- Faster Load Times
Pages that use a relative URL will load more quickly than pages using absolute URLs, for the most part, although the difference is miniscule at best.
Why Choose Absolute URL?
- Foils Scrapers
An absolute URL makes it harder for people to scrape information from your website using scraper programs. If you have all of your internal links as relative URLs, it would be very easy for a scraper to simply scrape your entire website and put it up on a new domain.
- Disallows Duplicate Content
It's very important to have absolute URLs in order to avoid duplicate content issue. Imagine you have multiple versions of root domains that are indexed in Google without a canonical tag point to correct version of the site. For example:
According to Google, these are 4 different sites and Google could potentially enter your site on any one of these four pages. At this point if all of the internal links are relative URLs, they can then crawl and index your entire site using whatever format these are eventually resulting in a duplicate content issue.
- Improve Internal Link Strategy
While coding URL, you do want to think about internal linking. If you have a <base href> tag that was implemented wrong on the site along with relative URLs, it will create a page that will land on 404 error page.
For ex: on your category page http://www.example.com/category/xyz.html, you have base href tag that reads:
<base href="http://www.example.com/category/xyz.html"/> and relative URLs internal link(/category/abc.html). When Google crawls your internal links, it will result in 404 error page as shown below.
With the use of Absolute URLs, you are avoiding this type of situation.
- Helps With Crawling
Google crawlers follow the internal links on your pages to crawl more dip pages on your site. There is a limited number of URLs that Google crawlers crawl due to the actual cost involved in it. Based on this fact if you have a million pages on your site and during the crawl if Google comes across an issue more frequently, then it would be more logical for them to leave the site.
This situation can be avoided by using the absolute URL to help Google streamline the crawling process, which will not only save time but also encourage it to come back more often and crawl more pages.
Make sure that you pick the appropriate strategy according to your SEO needs. For the most part, it will be absolute URLs as it definitely has more pros than cons and will help improve your site's SEO. However, there are times you will use relative URLs as well depending on the need of your site.