【发布时间】:2020-04-14 09:49:54
【问题描述】:
我在我的 react 项目中使用 react-helmet。
我的 index.html 中的元标记是:
<link rel="canonical" href="https://example.com" />
<meta name="description" content="main description">
在组件中,我将元标记设置为:
const ContactUs = () => {
return (
<div className="less-content-container justify-content-start align-items-start">
<Helmet>
<title>Contact Us | Example</title>
<meta name="description" content={"contact us description"} />
<link rel="canonical" href={"https://example.com/contact-us"} ></link>
</Helmet>
</div>
);
}
当最终联系我们页面在浏览器中呈现时,我在 Chrome 检查中看到呈现的 html 中的两组元标记。第一组元标记是 index.html 的元标记,第二组元标记是在组件中声明的。
另外,在 Google 网站管理员控制台中,我看到 User-declared canonical 设置为无。这意味着。 Google 爬虫未读取规范元标记。
【问题讨论】:
标签: reactjs react-helmet