我有一个专为桌面设备设计和优化的页面 foo.bar/root
,现在我想告诉搜索引擎 m.foo.bar/m-root
是同一个页面,但针对移动设备进行了优化,我该怎么做?
我应该在我的响应中添加什么样的标签(或 http header )来告诉亲爱的 Google 索引移动优化页面?
最佳答案
alternate
link type “创建引用当前文档的替代表示的超链接”。使用 link
元素,它可能看起来像:
<!-- on the desktop page <http://example.com/foo/> -->
<link href="http://m.example.com/foo/" rel="alternate">
您还可以使用 media
attribute指定“资源适用于哪些媒体”(根据您的喜好调整媒体查询):
<!-- on the desktop page <http://example.com/foo/> -->
<link href="http://m.example.com/foo/" rel="alternate" media="only screen and (max-width: 640px)">
这是普通的 HTML5 方式。
根据 Google’s documentation , Google 似乎也能识别此标记。
关于html - 指出桌面版中的移动优化页面(html),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27845680/