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?
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.
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.
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.
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).
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With