[英]How to modify JSON-LD in the header after page load, asynchronously
在页面加载开始时,我将JSON-LD数据添加到标题中:
<head>
...
<script type="application/ld+json">
{
"@context":"http://schema.org",
...
}
</script>
</head>
后来,我也想添加一些额外的异步数据,因为Google能够对其进行爬网 。
想知道如何更改标头中的现有JSON-LD数据?
您可以使用react-helmet
并呈现模式脚本:
import { Helmet } from "react-helmet";
const schema = {
"@context": "http://schema.org",
"@type": "Person",
"name": "John Doe"
...
}
<Helmet>
<script type="application/ld+json">
{JSON.stringify(schema)}
</script>
</Helmet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.