大型网站的最佳做法

问题描述 投票:0回答:1

我在一个大型网站上工作,并且想要实现JSON-LD 。 该网站拥有大量的社交媒体关注者,以及很多艺术家简介和文章。

这就是我目前所拥有的(以下代码来自Google的准则)

首页

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "name": "Organization name",
  "url": "http://www.your-site.com",
  "sameAs": [
    "http://www.facebook.com/your-profile",
    "http://instagram.com/yourProfile",
    "http://www.linkedin.com/in/yourprofile",
    "http://plus.google.com/your_profile"
  ]
}
</script>

内容页

<script type='application/ld+json'> 
{
 "@context": "http://www.schema.org",
 "@type": "WebSite",
 "name": "About us",
 "url": "http://www.your-site.com/about-us"
}
</script>

每个艺术家的个人资料页面:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "NewsArticle",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://google.com/article"
  },
  "headline": "Article headline",
  "image": [
    "https://example.com/photos/1x1/photo.jpg",
    "https://example.com/photos/4x3/photo.jpg",
    "https://example.com/photos/16x9/photo.jpg"
   ],
  "datePublished": "2015-02-05T08:00:00+08:00",
  "dateModified": "2015-02-05T09:20:00+08:00",
  "author": {
    "@type": "Person",
    "name": "John Doe"
  },
   "publisher": {
    "@type": "Organization",
    "name": "Google",
    "logo": {
      "@type": "ImageObject",
      "url": "https://google.com/logo.jpg"
    }
  },
  "description": "A most wonderful article"
}
</script>

我要在每页上添加一个脚本标签还是在一个脚本标签下添加所有JSON-LD ? 在首页上,我具有“组织”标签并显示社交媒体链接,是否可以在所有页面上添加此链接?

json-ld
1个回答
1
投票

可能在页面上多个script JSON-LD数据块,但是使用一个script元素可以更轻松地连接结构化数据实体:您可以嵌套实体,而不必引用它们的URI

要连接什么? 您的NewsArticle可以

  • 提供WebPage ¹实体作为值mainEntityOfPage属性,和
  • 提供Organization实体作为publisher属性的值。

这只是一种可能性。 另一个:您可以将WebPage实体作为顶级项目提供,并将NewsArticle实体作为mainEntity属性的值提供。

如果有重复的数据(例如,因为该Organizationauthorpublisher ,还是因为它的publisher都后, WebPageNewsArticle ),你可以混合嵌套和引用。 给每个实体一个@id ,无论您在何处提供该实体作为值,也要提供其@id


¹您正在使用WebSite ,但您可能指的是WebPage 。 还要注意,@ @context应该是http://schema.org ,而不是http://www.schema.org

© www.soinside.com 2019 - 2024. All rights reserved.