How the hreflang is supposed to be built?

泪湿孤枕 提交于 2019-12-02 17:53:10

问题


My question is does the

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

should be like above an all pages or should be changed with the actual url of every page like:

<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">

回答1:


HTML5 defines:

If the alternate keyword is used with the hreflang attribute, and that attribute's value differs from the root element's language, it indicates that the referenced document is a translation.

So it’s for translated documents (i.e., pages), not sites.

http://example.com/en links to http://example.com/it,
http://example.com/en/hello links to http://example.com/it/ciao.



来源:https://stackoverflow.com/questions/31248004/how-the-hreflang-is-supposed-to-be-built

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!