我的问题是
<link rel="alternate" href="http://example.com/en" hreflang="en">
<link rel="alternate" href="http://example.com/it" hreflang="it">
应该像上面的所有页面一样,或者应该用每个页面的实际 url 来改变,比如:
<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">
最佳答案
HTML5 defines :
If the
alternate
keyword is used with thehreflang
attribute, and that attribute's value differs from the root element's language, it indicates that the referenced document is a translation.
因此它适用于翻译的文档(即页面),而不是网站。
http://example.com/en
链接到 http://example.com/it
,
http://example.com/en/hello
链接到 http://example.com/it/ciao
。
关于php - hreflang 应该如何构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31248004/