Relative URLs may be misinterpreted by search engines, so it’s recommended they are fully qualified URLs as part of your hreflang tag

Google offers the following example of valid vs. invalid hrefs:

  • Correct: https://example.com/foo
  • Incorrect: //example.com/foo 
  • Incorrect: /foo 

A qualified URL includes the hypertext transfer protocol (i.e. http) and the full domain. And so, it provides all the information of that specific URL, instead of just parts of it. Hence its alternate name, absolute! 

If your URLs are relative, you can update them to be absolute. Here’s how.

Table of Contents

The Importance of Absolute URLs

Relative URLs can be misinterpreted by Googlebot, so they might not be indexed. This would cancel out the benefit of adding hreflang. 

As for your absolute URLs, they are fully qualified, so Googlebot is less likely to misinterpret them. Remember, an absolute URL includes all relevant information, even the transport method (i.e. http or https). 

How to Update Relative URLs

Changing the URL used in your hreflang tag requires updating the href attribute. There’s no need to add or delete any elements to resolve this issue. The update here involves filling in the pieces of the URL that are missing. 

If the URL used in your hreflang only includes the domain and path (i.e. //example.com/foo) or just the specific subfolder (i.e. /foo) you’ll want to update these relative URLs to be absolute. 

Here’s what an absolute URL would look like:

https://example.com/foo

The country and language code of your hreflang tag can stay the same, this issue only rests with the URL. 

Since hreflang is a part of your site’s code, you’ll need backend access to make the change. If you don’t have these access permissions, the dev team should be able to help you out. 

How to Solve at Scale

Diving directly into your site’s code is one way to change your hreflang URLs from relative to absolute. However, this solution operates on a page-by-page basis. 

To make mass changes across your site, you can leverage SEO execution platform ClarityAutomate. With this approach, a few clicks is all it takes to update your hreflang across thousands of pages. Here’s how. 

  1. Select what you'd like to optimize: Code
    Since hreflang is part of your site’s code, that’s what we’d select within ClarityAutomate.
  2. Choose how you'd like to optimize it: Update
    We need to change those relative URLs to be absolute, so we select “update”. (For other optimizations, you also have the option to add or delete elements!)
  3. XPath location: XPath of the hreflang with the relative href
    This step lets us focus on the specific part of the code with the relative href. 
  4. Attribute: href
    The specific attribute within the hreflang is the href. 
  5. New Value: A fully qualified URL for the href
    All that’s left to do is set the new absolute URL in the href field. 

Before and After

This href grew from: /playbook/hreflang_rel_links.html"  

To this: https://seoautomation.io/playbook/hreflang_rel_links.html" 


 

Looking for other hreflang issues?