Mobile app version of vmapp.org
Login or Join
Annie201

: Can a element's href attribute be relative? Can I use: <link rel="alternate" hreflang="en" href="?l=en" /> to link pages with different languages for SEO (recommended for example by Google)?

@Annie201

Posted in: #Html #Hyperlink #Language #RelativeUrls #Seo

Can I use:

<link rel="alternate" hreflang="en" href="?l=en" />


to link pages with different languages for SEO (recommended for example by Google)? Can that URL be relative as in the example above, or does it have to be full (start with example.com)?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Annie201

3 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

Yes.

The definition of the href attribute for the link element says:


[…] must contain a valid non-empty URL potentially surrounded by spaces


This links to the definition of valid non-empty URL, which links to the definition of valid URL, which says that is has to be a URL that


conforms to the authoring conformance requirements in the URL standard


That URL standard is www.w3.org/TR/url/ (which is actually only a Working Draft from 2014), and this, of course, defines/allows relative URLs.

Or in other words (tl;dr): The href attribute is the same for a, area, and link.

10% popularity Vote Up Vote Down


 

@Gretchen104

If possible do always use absolute links instead of relative ones.

Why?

Because relative links may cause crawl errors. Especially when it comes to alternate links you should make sure the bot finds exactly the URL you want it to crawl.

Further it is not a good idea to use parameters for language indication.

Please visit the following guides on multi language websites: support.google.com/webmasters/answer/182192?hl=en
And implementing hreflang: support.google.com/webmasters/answer/189077?hl=en

10% popularity Vote Up Vote Down


 

@Nickens628

Looks like it. This example comes from the HTML5 specs:


For example, the following link is a French translation that uses the
PDF format:

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme