Chat with us, powered by LiveChat
Types of URL (Absolute and Relative) and Their Differences

Types of URL (Absolute and Relative) and Their Differences

Types of URL (Absolute and Relative) and Their Differences

Uniform Resource Locators (URLs) are essential elements of all websites. As the name suggests, they allow search engines and users to locate and access the resources you have made available online. Essentially, they are the web addresses of your web pages, images, videos and any other resource you have published to your website.

The way a URL is structured plays an important role in enabling your website to be properly crawled and indexed by search engines. Without the right structure, parts of your website might not be findable by search engines and would, therefore, be unavailable to your visitors.

There are two types of URL that you can have on a website: absolute URLs and relative URLs. In this post, we’ll look at these two versions, showing the difference between them and explaining what use each is suited for.

Absolute URLs

An absolute URL contains the entire address of the resource which it points to and usually has the following structure:

protocol://domain/path

  • The protocol is usually http:// or https:// (though it could also be ftp:// or file://.
  • The domain is the name of your website, e.g. yourbusiness.com
  • The path is the pathway of the directory and sub-directories to where the file is located and the name and extension of the file. e.g. wordpress/wp-contents/includes/file1.html

The complete absolute URL, for example, would be:

https://yourbusiness.com/wordpress/wp-contents/includes/file1.html

Relative URLs

While an absolute URL can locate a file from anywhere on the internet, a relative URL can only be used to locate a file if you are on the same website. Rather than give an absolute address, it shows where the file is in relation (hence the term ‘relative’) to where you currently are on the website. Assuming that the visitor is already within the website, a relative URL only contains the domain followed by the location, e.g.

<a href = “/file1.html”>

Why use relative URLs?

Faster coding and development

You can code a website far easier if you only need to use, shorter relative URLs. If you are developing a website and have live and developmental versions with different domains, relative URLs allow you to bring your newly developed site online without having to modify all the URLs to those of your live site.

Internal linking

Remember, relative URLs can only be used to link to resources with the same root directory.

Why use absolute URLs?

Makes it difficult to clone your site

Cloned websites are used by cybercriminals to defraud a company’s customers. To create clones, they use scraping tools that search and copy a site’s content. Absolute URLs make it more difficult for them to do this.

Stops duplicate content

Duplicate website content can impact your SEO and your site’s ranking. Absolute URLs help prevent duplicate content issues. Search engines, for example, consider the http://, http://www, https:// and https://www versions of a website as different websites. If all these versions were crawled and the site used relative URLs, it could lead the search engines to index four versions of each of your web pages. As absolute URLs contain the specified protocol, this cannot happen.

Assists with search engine indexing

Search engine crawlers index your site by following internal links. However, they don’t always search the whole site. Using absolute URLs, however, makes it easier for them to index more of your site quickly so that more of your pages are searchable online.

Conclusion

Absolute and relative URLs are both ways to structure your site and link to its resources. There are advantages and disadvantages to each. While absolute URLs provide better security and improved SEO, relative URLs are quicker and easier to use when developing websites.

For information about our hosting solutions, visit our homepage.

Sharing

Leave your comment

Pin It on Pinterest

Share This