Should I Use Relative or Absolute URLs?
A well-thought-out URL structure plays an important role for successful website promotion and user experience. Is it correct to configure all links on the site using both relative and absolute formats? Which format is more efficient? It is recommended to fully understand this issue and the possible consequences of the wrong approach to structuring URLs.
What Is an Absolute URL
An absolute URL shows all the information about the full page address in the search engine and all the steps you need to go through to get to the page, including the protocol and domain. Links like this can be searched from anywhere on the Internet, not just on one site.
Absolute paths are inflexible and do not automatically adjust to the content on the page or changes. Moreover, absolute links are always unique. A single page, document, or directory on the web are all opened using only one absolute path.
What Is a Relative URL
The relative URL shows where you are already located. Such addresses do not contain information about the protocol and domain. They only show part of the path to the page.
Relative URLs take into account the argument that the server already knows where the page is located. Therefore, Google makes assumptions itself about the domain. Sometimes this leads to search engine errors, sending users to the wrong pages.
For example, the relative path for /duplicate-content is /blog/duplicate-content. The search engine has to guess on its own that this address refers to https://www.seoquake.com.
Relative URLs are good for lightweight platforms. They make website management easier. If you need to transfer a web resource to another domain, links with relative addresses will automatically redirect to the correct domain.
Such a system is not suitable for sites with complex architecture. If the web platform has many categories, subcategories, and products, relative paths can reduce the importance of internal links. Especially if they are not canonized. Read more – Rel=Canonical Tag.
Relative vs. Absolute URL
The main difference between absolute and relative paths is that absolute URLs always include the domain name of the site with http://www. Relative links show the path to the file or refer to the file itself.
A relative URL is useful within a site to transfer a user from point to point within the same domain.
Absolute links are good when you want to send the user to a page that is outside of your server.
Pros and Cons of Relative URLs
- Simplified coding
Web developers often make life easier for themselves by using relative links for their site. When there are hundreds of pages on a resource, it is tedious and time-consuming to write the entire path for each one. Instead, indicating a point on the site map will make it clear that the page belongs to a specific server.
- Fast transition of the site into working
When you use an absolute URL for each page of the site, and it becomes necessary to transfer the portal to a new domain, there may appear certain difficulties. Hundreds, thousands of URLs need to be re-encoded for a new domain. With relative URLs, you can avoid this problem. All relative links will immediately start working on the new domain, without the need to recode each of them separately.
- Increase download speed
Short URLs help pages load faster. This is a minor speedup, so you shouldn’t rely on relative URLs alone. They won’t solve all problems of a site with slow page loading. To help your site run faster, dig deeper. You can do this by checking image sizes and using Google Tag Manager. You may face more serious problems as well. More information in articles – SEO Images and Google Tag Manager.
- Duplicate pages
One relative URL can duplicate itself four times in absolute one:
- http: // www. examplewebsite.com
- http: //examplewebsite.com
If you do not define any of the URLs as canonical, each duplicate will be indexed by Google as a unique page. For you, these four pages are one domain, but for Google, these are four separate sites.
To avoid this, solve the server issues.
Check out of the four variants of the site domain, and identify the main one.
HTTPS is better than HTTP. Google talked about this. The search engine respects safe sites and immediately shows users that such a site can be trusted.
A secure connection ensures user security in three ways:
- User information cannot be stolen nor tracked.
- Files are not damaged in transit.
- HTTPS protects against hacker attacks and gives more confidence to visitors.
Not using www is better using it. It does nothing other than familiarizing the look of the address and increasing the length of the URL by four characters. This can have a subtle impact on SEO.
Not sure what to choose? For the main address of the web platform, it is better to choose the format https://examplewebsite.com and set redirects from others to it. This will give you more credibility from Google. Without www, the link is shorter and the search engine prefers addresses whose security is reinforced by the HTTPS protocol. More information in the article – HTTPS vs. HTTP.
In fact, whichever address you choose, the main point is that all of them direct the user to the main version.
If you do not choose one URL, then each of the pages of the site will open at four potential URLs. For promotion and optimization, this will not bring any benefit and all you can do is divide the effectiveness of the site by four.
Another downside to getting into a situation like this is that Google has a limited crawl budget. This means that the search engine allocates a specific time that it is ready to spend on crawling resource links. As soon as it ends, Google considers its work to be done and you are left without ranking in search results with a complex site on your side.
Duplicate content causes Google to waste time crawling the same page multiple times. THisis instead of crawling and promoting other more important platform content. This is because the page has duplicated itself in several versions.
Google won’t dig deep. It is important to adjust the site structure to the search engine standards and user experience.
- Stealing content
Relative URLs help you avoid the effort of re-encoding addresses for migration from your staging environment to your production domain. However, if you use relative addresses for all internal links of the site, then it can easily be stolen. The hacker will easily redirect all links to the new domain.
To avoid this, fix internal links.
After the changes on the server, challenge the developers to recode the relative paths to the absolute ones. It is advisable to start with the addresses in the site navigation.
After the conversion is complete, check the site for broken links and relative URLs that are still there. To do this, use the Screaming Frog tool. Read more – What Are Bad Links?
- Deteriorating of linking
Internal linking plays an important role on the site. Therefore, you need to pay attention to how you use the internal linking tags. There is a rumor in the SEO community that relative URLs occasionally lead to a huge number of 404 errors. John Mueller refuted this idea. The SEO specialist claims that a properly configured link will be read by Google bots anyway. It doesn’t matter if it is relative or absolute. Errors will start to appear anyway if there are inaccuracies when setting the URL.
It’s important to carefully rewrite the URL if you need to. Often the problems that arise when scanning links are directly related to writing the addresses incorrectly.
If you want but can’t take the time to fix links from relative to absolute, use canonicalization of pages.
Add a rel=canonical tag to all duplicate content pages. This will show the search engine which links are the main ones.
The canonical tag protects not only from duplicate content but other content as well. If the site is attacked by scrapers and data is stolen, canonical tags will remain on the copied pages. Thanks to this, search bots will know that this version of the site is not real.
Relative URLs are not the most reliable choice. If there is no other way out, you can hold the site on relative links. Absolute links are what you need to lead your resource to.
Pros and cons of absolute URLs
- The link points to the correct URL all the time.
Absolute links do not generate multiple URL variations, so Google is not confusing anything. The search engine will invariably know which address to follow.
- It makes it difficult to steal content.
When a site uses absolute URLs to steal content, a hacker will have to rewrite each platform URL. Not many are ready for this. Even if someone decides to steal the site, internal links will still point to your domain.
- Prohibits duplicate content
With absolute URLs, instead of four duplicates of the site, there will only be one resource indexed by the search engine.
- Simplifies site crawling process for Google
If Google encounters problems on the site, then the most logical solution for the search engine would be to simply leave the website. Absolute URLs can help you avoid this. They make the scanning process easier and encourage the search engine to come back to your site more often.
- Not suitable for testing
Testing a site with absolute URLs takes an incredible amount of effort. This may not be worth the time.
Absolute vs. relative URLs for SEO
10 years ago, Google expert John Mueller argued that in his personal practice, he prefers relative URLs. They are easier to work with when testing links and moving content. The SEO specialist applied absolute paths to shares without specifying a domain name.
At that time, absolute links were not a priority, and they were often used only when there was a possibility of encountering duplicate content. At this point, it was not possible to make a 301 redirect. Read more – 301 vs 302 redirects.
Everything has changed in the last 10 years.
When analyzing relative and absolute URLs, we found that absolute paths are leading in SEO:
- Absolute links help avoid duplicate content.
- They prevent problems with RSS feeds.
- They reduce the likelihood of theft of links to zero.
- In Google’s SERPs, absolute links to images claim ownership of them.
- Despite the lengthy re-coding of links, absolute URLs are easier to manage. With addresses like these, the probability of errors is lower when moving.
- Search engines always crawl absolute URLs.
With relative URLs, it’s still easier to migrate from domain to domain. However, newbies can run into problems setting up relative paths and make mistakes that easily ruin links. This will cause search engines to crawl your site incorrectly and lower your rankings. Therefore, we started to use absolute URLs more often. They help you avoid incorrect links. This is easier and safer than checking that the relative address is correct each time.
How to create effective absolute links
For those who are going to use absolute paths on the site, we have prepared some tips on how to adjust links to a single format:
- Choose HTTPS protocol. It is more reliable and secure for Google.
- Prepare your development team to recode all links on the site. It is preferable to do this with facts.
- Get in the habit of using Screaming Frog to find out in time about all links that do not fit the established URL format.
- Canonicalize all URLs that cannot be made absolute. This will reduce the likelihood of duplicate pages.
- Use the non-www version of the URL. This will shorten the length of the links.
You can use both link building methods. For more effective SEO, it is worth choosing which one to use.
If absolute links have so many upsides and relative downsides, then why are relative URLs still used?
The main reason is that relative links make it easier to run tests and move content from the test environment to the main environment. Not everyone wants to sit around re-coding all addresses after the next change that needs to be made.
Many SEO experts consider absolute links to be the best option for promotion. Before you recode the entire site, consider which option is right for you.
SEO consultant Dan Shure recommends using absolute links.
John Mueller argues that for search engine optimization there is no difference between absolute links and relative links.
From an SEO point of view, the most important thing is that the URL points to the correct point on the server.
There is no perfect solution to which URLs to use on the site. Both relative and absolute paths have pros and cons. Relative paths make the developer’s job easier and faster. Assess your own needs for your project. If you do a lot of testing and move content frequently between domains, then relative links are the best solution. Absolute paths are more secure, protect content, and prevent duplicate pages.
The main point is that the link format you prefer should be applied to all URLs on the site. This will reduce the chance of errors.