首页 > 解决方案 > Angular10将脚本标签添加到谷歌职位发布的索引中

问题描述

如果你想使用谷歌职位发布,你需要在 HEAD 中添加一个 scripttag。请参阅下面的示例,我将 JSON 做得更小一些。

<html>
  <head>
    <title>Software Engineer</title>
    <script type="application/ld+json">
    {
      "@context" : "https://schema.org/",
      "@type" : "JobPosting",
      "title" : "Software Engineer",
      "description" : "<p>Google aspires to be an organization that reflects the globally diverse audience that our products and technology serve. We believe that in addition to hiring the best talent, a diversity of perspectives, ideas and cultures leads to the creation of better products and services.</p>",
      "identifier": {
        "@type": "PropertyValue",
        "name": "Google",
        "value": "1234567"
      },
      "datePosted" : "2017-01-18",
      "validThrough" : "2017-03-18T00:00",
      "employmentType" : "CONTRACTOR",
      "hiringOrganization" : {
        "@type" : "Organization",
        "name" : "Google",
        "sameAs" : "http://www.google.com",
        "logo" : "http://www.example.com/images/logo.png"
      },
      
    }
    </script>
  </head>
  <body>
  </body>
</html>

我试图实现这个 bij 在特定组件中创建脚本元素。问题是这个脚本没有出现在页面源中。有没有办法做到这一点?

多谢

标签: angular

解决方案


是的,将script标签添加到index.html. 您不能将script标签添加到组件的 html 中,至少我不知道。


推荐阅读