为我的多语言Web应用程序定义Schema.org JSON-LD

时间:2018-09-11 15:49:43

标签: schema.org microdata json-ld

我正在构建一个用于产品比较的Web应用程序。该网站的结构如下:

http://example.com
http://example.com/fr/compare/
http://example.com/es/compare/

等等。

主页为英文。

我想为每个页面插入Schema.org,并且已经解释了该模式。我打算稍后在方括号中写上值。

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@id": "[canonical-url-for-specific-language]#webapp",
  "@type": "WebApplication",
  "name": "[Product Comparison Title in specific language]",
  "url": "[canonica url for specific language]",
  "applicationCategory": "Utility",
  "applicationSubCategory": "Product Comparison",    
  "about": "[page-description]",
  "browserRequirements": "Requires JavaScript. Requires HTML5.",
  "softwareVersion": "1.0.0",
  "screenshot": "[image-url]",
  "inLanguage": "[language-code]",
  "softwareHelp": {
    "@type": "CreativeWork",
      "url": "[link-to-how-to-page-for-specific-language]"
  },
  "operatingSystem": "All"
}
</script>

我怎样才能很好地构造此JSON-LD以使其适合我的特定网站。

1 个答案:

答案 0 :(得分:0)

如果将结构化数据用于具有语言选择器的主页,则标记可能类似于以下内容:

{
  "@context": "https://schema.org",
  "@id": "[canonical-url-for-specific-language]#webapp",
  "@type": "WebApplication",
  "name": "[Product Comparison Title in specific language]",
  "url": "[canonica url for specific language]",
  "applicationCategory": "Utility",
  "applicationSubCategory": "Product Comparison",    
  "about": "[page-description]",
  "browserRequirements": "Requires JavaScript. Requires HTML5.",
  "softwareVersion": "1.0.0",
  "screenshot": "[image-url]",
  "inLanguage":[{
      "@type": "Language",
      "name": "English",
      "alternateName": "en",
      "additionalType":"https://www.loc.gov/standards/iso639-2/php/code_list.php",
      "sameAs":"https://en.wikipedia.org/wiki/English_language"
    },
    {
      "@type": "Language",
      "name": "Spanish",
      "alternateName": "es",
      "additionalType":"https://www.loc.gov/standards/iso639-2/php/code_list.php",
      "sameAs":"https://en.wikipedia.org/wiki/Spanish_language"
    }],
  "softwareHelp": {
    "@type": "CreativeWork",
      "name":"Customer Service and Support",
      "url": [
      "https://examples.com/en/help.html",
      "https://examples.com/es/help.html"
      ]
  },
  "operatingSystem": "All"
}

请注意,我在这里为每种语言使用了两个标识符,其属性分别为 sameAs additionalType

如果网页使用一种特定语言,则只需删除标记中不必要的语言部分和方括号即可。

Google testing tool 上查看此标记,请注意,有两个警告可用于修复。