0

在页面加载开始时,我将 JSON-LD 数据添加到标题中:

<head>
  ...
  <script type="application/ld+json">
    {
      "@context":"http://schema.org",
      ...
    }
  </script>
</head>

后来我得到了一些我想添加的额外异步数据,因为谷歌能够抓取它

想知道如何更改标头中现有的 JSON-LD 数据?

4

1 回答 1

1

您可以使用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>
于 2017-06-02T08:32:14.117 回答