Absolute vs Relative URLs: when to use which for SEO?

Last updated: June 8, 2021

There are two main URL options to use on your website: absolute URLs and relative URLs. Both serve different purposes, so it’s important to choose the option that best fits your website from an SEO perspective.

What is an absolute URL?

An absolute URL is the full URL, including protocol (http/https), the optional subdomain (e.g. www), domain (example.com), and path (which includes the directory and slug). Absolute URLs provide all the available information to find the location of a page.

Here's an example of an absolute URL:

https://www.example.com/about/team/

What is a relative URL?

A relative URL is a URL that only includes the path. The path is everything that comes after the domain, including the directory and slug.

Because relative URLs don’t include the entire URL structure, it is assumed that when linking a relative URL, it uses the same protocol, subdomain and domain as the page it’s on.

Here’s an example of a relative URL:

/about/team/

Recommendations for using absolute vs. relative URLs

Both absolute and relative URLs can be viable options for your site. Here’s our recommendations for which URL to choose based on common use-cases, and why.

XML sitemaps: Absolute URLs

For the XML sitemap, we always recommend using absolute URLs.

While some use-cases below give you the option to choose, this one absolutely requires using absolute URLs. All the major search engines, including Google (opens in a new tab) and Bing (opens in a new tab), follow sitemap guidelines which require absolute URLs in the sitemap to minimize any confusion about which pages should be crawled and indexed.

Canonical URLs: Absolute URLs

For implementing canonical URLs, we recommend using absolute URLs too.

Think of canonical URLs as one of the first lines of defense — along with domain redirects — against duplicate content issues. You want to make it clear from the start what the preferred version of the page is and where it can be found.

Take for example:

<link rel="canonical" href="https://www.example.com/about/team/">

In comparison to a relative URL:

<link rel="canonical" href="/about/">

Using the relative URL as the canonical URL makes every page accessible via different variations of protocol and subdomains (unless you have domain redirects properly in place).

Hreflang attribute: Absolute URLs

For implementing the hreflang attribute, we recommend using absolute URLs. Again, you don’t want to leave any room for search engines to interpret URLs incorrectly so it’s best to provide the exact location of the URL from the very beginning.

This is also the recommended advice from Google (opens in a new tab).

If your site is properly configured, then the choice between absolute and relative URL links depends on how you set up your website as well as your individual preferences.

Working with multiple environments: Relative URLs

In order to easily work across multiple environments, we recommend relative URLs. Relative URLs make it easier to work with a staging environment besides the production environment — and avoids having to update links when you sync multiple environments.

Take for example the following staging environment:

https://staging.example.com/about/team/

When the page goes from staging to production, every absolute URL link will need changed from: https://staging.example.com/about/team/ to https://www.example.com/about/team/.

If a relative URL link /about/team/ is used, then you’ll be exempt from this tedious process.

Faster coding: Relative URLs

For faster and more effective coding, we recommend relative URLs. Rather than including the entire URL for each page you link, relative URLs cut down on the workload and time needed.

For example, coding /about/ is much faster than https://www.example.com/about.

Minimizing duplicate content issues: It depends

To minimize duplicate content issues, we recommend absolute URLs. Absolute URL links will make it crystal-clear to both visitors and search engines where to go.

This is especially important if your site is vulnerable to duplicate content issues, for example when your domain redirects or canonical URLs aren’t correctly set up. If this is the case for you and you are using relative URL links, Google could potentially see this as four different sites — non-www vs www and HTTP vs HTTPs.

Duplicate content due to different canonical domains.
Duplicate content due to different canonical domains.

As a result, any value attributed to that link could be lessened as it’s spread across four sites rather than just one. And these page variants may start competing with one another.

However, if your site structure is solid, it doesn’t matter if you use absolute or relative URLs to link internally (opens in a new tab), it will ultimately be a matter of preference and what makes sense for your site.

Read the full Academy article to learn everything about URL structure