我正在为 Rails 应用程序进行 SEO。
该网站已完全本地化,我正在关注 this google article向页面添加 hreflang 备用链接。
<head>
中的 HTML 链接没问题。
我在使用 response headers 时遇到了一些问题.
我知道我应该为页面的每个替代版本提供值,但我不确定如何设置多个值。
我尝试将它们作为逗号分隔列表 传递。浏览器似乎正确接收了它,但由于各个值包含分号,所以看起来错误。
有引用资料吗? 即使是已知可以正确实现它的示例网页也会有所帮助。
最佳答案
我没有这方面的经验,但根据 examples在同一个 RFC 中,它们用逗号分隔:
Link: </TheBook/chapter2>;
rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
</TheBook/chapter4>;
rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
由5.3间接证实(强调我的):
Note that extension relation types are REQUIRED to be absolute URIs in Link headers, and MUST be quoted if they contain a semicolon (";") or comma (",") (as these characters are used as delimiters in the header itself).
关于html - HTTP 响应 header : multiple Link values,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25369191/