我想将 JSON-LD 文章添加到博客模板

I want to add JSON-LD articles, to the blogger template

在互联网上,我从下面的 Json-LD 文章中获得了这段代码,但我不知道我必须在字段中添加什么代码:

[Article title]
[Article sub heading]
[Main article image url]
[Author name]
[Date in ISO format e.g. 2014-03-16]
[Article summary]

我也不知道,我必须把模板的哪一部分放进去。我对编程一窍不通

请你帮我把 json-ld 文章放在 contempo blogger 模板中

<script type="application/ld+json">
{ 
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "[article title]",
  "alternativeHeadline": "[article sub heading]",
  "image": "[main article image url]",
  "author": "[author name]",
  "datePublished": "[date in ISO format e.g. 2014-03-16]",
  "description": "[article summary]"
}
</script>

在 Blogger 发布的新主题中(比如您正在使用的 Contempo 主题),他们包含了一个新的数据标签,用于自动生成 post 的 JSON-LD 数据。负责这个的标签是 -

<b:include data='post' name='postMetadataJSON'/>

默认生成如下数据-

<script type='application/ld+json'>
{
    "@context": "http://schema.org",
    "@type": "BlogPosting",
    "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "POST-URL"
    },
    "headline": "POST TITLE",
    "description": "POST SNIPPET",
    "datePublished": "DATE-PUBLISHED",
    "dateModified": "DATE-MODIFIED",
    "image": {
        "@type": "ImageObject",
        "url": "IMAGE-URL",
        "height": 630,
        "width": 1200
    },
    "publisher": {
        "@type": "Organization",
        "name": "Blogger",
        "logo": {
            "@type": "ImageObject",
            "url": "BLOGGER-LOGO",
            "width": 206,
            "height": 60
        }
    },
    "author": {
        "@type": "Person",
        "name": "AUTHOR NAME"
    }
}
</script>

此标签默认包含在所有新主题中,因此您不必从您身边添加它。

您可以通过在 <b:includable id='post' var='post'>

之后放置代码来制作自定义主题
<b:includable id='post' var='post'>
<script type='application/ld+json'>
  <-- ld json content -->
</script>
<-- other code -->

例子

<script type="application/ld+json">
{ "@context": "http://schema.org", 
 "@type": "BlogPosting",
 "headline": "<data:post.title/>",
 "alternativeHeadline": "<data:post.title/>",
 "mainEntityOfPage" : "<data:blog.homepageUrl/>",
 "image": {
     "@type" : "imageObject",
     "url" : "<data:post.firstImageUrl/>",
     "height": "480",
     "width": "720"
 },
 "publisher": {
     "@type" : "organization",
    "name" : "Organization Name",
    "logo": {
        "@type" : "imageObject",
        "url" : "http://logo-url.png"
    }
 },
 "url": "<data:post.url.canonical/>",
 "datePublished": "<data:post.timestampISO8601/>",
 "dateCreated": "<data:post.timestampISO8601/>",
 "dateModified": "<data:post.timestampISO8601/>",
 "description": "<data:blog.metaDescription/>",
 "articleBody":"<data:post.body.jsonEscaped/>",
   "author": {
    "@type": "Person",
    "name": "<data:post.author/>"
  }
 }
</script>

查看 This Article 了解详细说明。