结构化数据标签的生成无法通过GoogleBot在Angular Spa应用程序上查看

发布于 2025-02-11 17:54:38 字数 753 浏览 3 评论 0原文

在Google搜索控制台上实时测试URL时,GoogleBot可以呈现页面,但我的结构化数据丢失了。它是在JS中生成的:

insertStructuredData(genDataFn: Function): void {
    this.removeStructuredDataElement();

    let script = this.getStructuredDataElement();
    if (!script) {
      script = document.createElement('script');
      script.type = 'application/ld+json';
      script.id = STRUCTURED_DATA_TAG_ID;
      document.head.appendChild(script);
    }

    safeScriptEl.setTextContent(script, scriptFromJson(genDataFn()));
  }

当我自己查看页面时,它显示得很好:

<script type="application/ld+json" id="structuredDataScriptTagId" nonce="abcdefg">...</script>

但是,当我查看GoogleBot在实时测试中看到的HTML时,该标签在页面中缺少。这纯粹是一个延迟问题,还是有其他影响该标签对Googlebot的可见性的东西?

When live testing a URL on Google Search Console, Googlebot can render a page but my structured data is missing. It is generated in JS via:

insertStructuredData(genDataFn: Function): void {
    this.removeStructuredDataElement();

    let script = this.getStructuredDataElement();
    if (!script) {
      script = document.createElement('script');
      script.type = 'application/ld+json';
      script.id = STRUCTURED_DATA_TAG_ID;
      document.head.appendChild(script);
    }

    safeScriptEl.setTextContent(script, scriptFromJson(genDataFn()));
  }

When I view the page myself it shows up just fine:

<script type="application/ld+json" id="structuredDataScriptTagId" nonce="abcdefg">...</script>

But when I view the HTML that Googlebot see on the Live test, this tag is missing from the page. Is this purely a latency issue or could there be anything else impacting this tag's visibility to Googlebot?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吹泡泡o 2025-02-18 17:54:38

您可以检查一些事情:

  1. 确保您的JSON-LD对象有效并且不包含错误。您可以使用富含结果测试工具来验证您的实现。
  2. 查看您网站上的灯塔报告,并确保您的页面在合理的时间内加载,并且在页面加载时,在DOM中尽快将JSON-LD包含在内。
  3. 数据,因此请确保您正在使用的结构化数据对象得到Google的支持,请查看在此处搜索库

基本上,您可以做到,但是即使到那时,Google仍会决定是否使用结构化数据对象上定义的数据;正如他们在官方文档中所说的那样搜索结果中的实际外观可能不同

There are a few things that you can check:

  1. Make sure your json-ld object is valid and doesn't contain errors. You can use the Rich Results Test tool to validate your implementation.
  2. Review the lighthouse report on your website, and make sure that your page is loading on a reasonable time and the json-ld is being included as soon as possible in the DOM when the page loads.
  3. Google Doesn’t Read Unsupported Structured Data, so make sure the structured data object you are using is supported by Google, take a look to the Search Gallery here.

That's basically al you can do, but even then, Google will decide whether to use or not the data defined on your structured-data objects; as they have stated on the official documentation The actual appearance in search results might be different

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文