php - hreflang 应该如何构建?

标签 php html seo multilingual rel

我的问题是

<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 the hreflang 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/

相关文章:

php - 返回列别名作为关联数组键

html - 更改 Bootstrap 工具提示颜色

PHP MAMP 未显示所有 HTML 文档

url - 不同大小写的链接之间的区别

indexing - 阻止某些地址被抓取 Robots.txt

SEO 问题 - Google 没有通过 cookies?

php - Zend Framework 1 apache2 虚拟主机配置

php - Swift Mailer - 无法发送邮件,也找不到错误日志

javascript - 如何在javascript中获取php echo结果

javascript - 将选定的复选框复制到另一个 div 中