Is it better to use relative or absolute URLs for the site and the SEO?

Put us to the test
Put us to the test!
Analyze your site
Select the database

Often the SEO lives on hamletic doubts, especially in the management of some technical aspects such as URLs: if in some cases the best practices leaning in a net way for a solution, as for the talking urls, in other circumstances the opinions are more divisive, for example when it comes to query strings or the choice between subdomain and subfolders. Another one of these ultimatum was at the center of the new #Askgooglebot pill on YouTube, with John Mueller who dedicated an episode to trying to clarify the differences between absolute and relative Urls and whether there is a preference in the way a search engine scans and indexes these addresses.

What Absolute URL and Relative URL mean

URLs are the basis of all websites and represent in a standard way the location of a generic resource to which the user can access; the localization of a web page can be done by providing an absolute or relative URL address.

The absolute URL is a complete address, which includes all the data needed to access that page, file or resource – protocol, server, absolute path and document name: as Mueller says, it is equivalent to “provide someone with the full address of a place they are trying to reach”.

The relative URL is a partial address, related to the location where the user is at that time on the site, and associate the code to the directory structure or the current file. Taking the example of road signs, the Googler explains that it is like saying to a person “go to the greenhouse straight down the street”.

Le differenze tra URL assoluti e URL relativi

Even more precisely, also following the indications of this Microsoft guide, an absolute URL uses the format < schema://server/path/resource >, while “a relative URL identifies a resource using an absolute URL as a starting point“, as the full destination URL “is specified by chaining the absolute and relative Urls“.

The relative URL is usually composed only by the path and, optionally, by the resource, while the schema and the server are absent. In practice, with the relative addresses it seems to miss everything except the name of the file, and the browser understands that to complete the URL and actually reach the page must use the path of the current folder.

It may be useful at this point to clarify the terminology of the URL:

  • Schema, which specifies how to access the resource.
  • Server, the part that specifies the name of the computer where the resource is located.
  • Path, that specifies the sequence of directories that lead to the destination. If the resource/resource is omitted, the destination is the last directory in the path.
  • Resource, is the destination, usually the name of a file. It may be a simple file, containing a single binary stream of bytes, or a structured document, containing one or more files and binary streams of bytes.

Absolute or relative URLs: what is the best choice for the site

In practical terms, setting an absolute URL or a relative URL obviously generates a difference for the site.

In the first case, the address contains more information and makes precise reference to a single location and a single file; in addition, the use of absolute Urls is mandatory for outbound links, which therefore have a different domain name, because otherwise they cannot be correctly detected by the browser.

The problem with absolute Urls arises in case of any migration or transfer of the site, because if we move the site to another server or another domain, We must necessarily rewrite all the addresses to enable resources to be effectively reached.

It is (also) for this reason that, usually, relative Urls are considered more valuable and convenient, which are shorter and more portable – although, as pointed out, they only serve to refer to links that reside on the same server as the current page. In case of migration, in fact, it will not be necessary to rewrite all the Urls of the pages nor to correct the internal links between the pages of the site, because these resources will always correctly work regardless of their location, without addressing errors.

In addition, the relative addresses are also recommended for sites organized in directories, because they facilitate the management of the multitude of pages registered and grouped into multiple folders, as they provide only the information strictly necessary to find the pages within the site.

Which option to choose for the SEO

The difference between absolute URL and relative URL therefore has a technical and practical explanation; but what is Google’s position, and so what is the best choice for the SEO?

According to John Mueller, there is actually no preferred or perfect solution because, “if correctly implemented, both of these approaches lead to exactly the same location” and therefore for Google Search “it does not matter at all which of these you use on the site”.

Nuovo episodio della serie di Google che risponde alle domande degli utenti

In terms of optimization and ranking, therefore, “Google treats both exactly the same way”, and indeed we can “also use both types of Urls within the same website, because there is absolutely no relative difference”.

What counts for the Search and, more generally, for the search engines is to have a unique URL available per content element, which then allows you to scan and index those contents in order to present them to users, but the way we secure this request is at our discretion.

Try SEOZoom

7 days for FREE

Discover now all the SEOZoom features!
TOP