Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are relative links valid in <link rel="alternate" hreflang="..." /> tags?

Tags:

html

Google's use of hreflang is documented here and all the examples have absolute links but there's no mention of absolute links being required or not. I found one post on a Google group saying they are required to be absolute but it doesn't seem authoritative and there's no reference. On the other hand W3C has this example:

<link rel=alternate type=application/pdf hreflang=fr href=manual-fr> 

Can anyone settle this?

like image 511
Andrew Magee Avatar asked Feb 03 '15 04:02

Andrew Magee


People also ask

What are hreflang tags used for?

The hreflang attribute (also referred to as rel="alternate" hreflang="x" ) tells Google which language you are using on a specific page, so the search engine can serve that result to users searching in that language.

What is the hreflang tag in HTML?

Hreflang is an HTML attribute used to specify the language and geographical targeting of a webpage. If you have multiple versions of the same page in different languages, you can use the hreflang tag to tell search engines like Google about these variations. This helps them to serve the correct version to their users.

What is link rel alternate?

link rel="alternate" media. Mobile attribute implementation. The rel="alternate" media attribute, mobile attribute for short, is used to indicate a relation between a desktop and a mobile website to search engines. Using the mobile attribute is only necessary if you have a separate desktop and mobile website.

What are relative links in HTML?

Relative hyperlinks are addresses that are relative to the current domain or location. They only contain the name of the target page prefixed with any necessary folder moves (for example, default. html).


2 Answers

Google says clearly in this April 2013 post (under "Mistake 2") that they consider the link tag to accept relative as well as absolute links.

like image 159
GreenReaper Avatar answered Oct 04 '22 10:10

GreenReaper


The other answer (from 2015) is wrong.

Here's what the spec says today:

Alternate URLs must be fully-qualified, including the transport method (http/https), so: https://example.com/foo, not //example.com/foo or /foo

enter image description here


You can also test your site using https://technicalseo.com/tools/hreflang/, it'll clearly tell you relative urls aren't supported.


I believe alternate is the keyword here, standard <link> can use relative paths, but rel=alternate links must use absolute urls.

like image 41
Vadorequest Avatar answered Oct 04 '22 12:10

Vadorequest