How is hreflang supposed to be built?

My question is what

<link rel="alternate" href="http://example.com/en" hreflang="en">
<link rel="alternate" href="http://example.com/it" hreflang="it">

should be like above all pages or should be changed with the actual URL of each page, for example:

<link rel="alternate" href="http://example.com/en/<?=$current;?>" hreflang="en">
<link rel="alternate" href="http://example.com/it/<?=$current;?>" hreflang="it">
<link rel="alternate" href="http://example.com/<?=$current;?>" hreflang="x-default">
0
source share
1 answer

HTML5 defines :

If the keyword is alternateused with an attribute hreflang, and this attribute value is different from the language of the root element, it indicates that the referenced document is a translation.

So, this is for translated documents (i.e. pages), not sites.

http://example.com/enlinks to http://example.com/it,
http://example.com/en/hellolinks to http://example.com/it/ciao.

0
source

All Articles