Skip to content

doJsonLd

Somya Dwivedi edited this page Oct 26, 2020 · 13 revisions

Guides

Configuration options

W3C Configuration options

Linter rules

Internal properties

Handled by ReSpec for you.

Special <section> IDs

HTML elements

Custom Elements

WebIDL

HTML attributes

CSS Classes

Special properties

Clone this wiki locally

doJsonLd

Adds a JSON-LD script element containing schema.org information, which can be useful for search engines.

The following entry in respecConfig can be used to configure JSON-LD support, which currently defaults to false.

var respecConfig = {
  doJsonLd: true,
};

In addition, you will also need to provide a canonicalUri and a license in your respecConfig for the JSON-LD data to be generated.

When configured, a script element similar to the following will be added:

<script type="application/ld+json">
  {
    "@context": [
      "https://schema.org",
      {
        "@vocab": "https://schema.org/",
        "@language": "en",
        "w3p": "https://www.w3.org/2001/02pd/rec54#",
        "foaf": "http://xmlns.com/foaf/0.1/",
        "datePublished": { "@type": "xsd:date" },
        "inLanguage": { "@language": null },
        "isBasedOn": { "@type": "@id" },
        "license": { "@type": "@id" }
      }
    ],
    "id": "https://w3c.github.io/some-API/",
    "type": ["TechArticle"],
    "name": "Replace me with a real title",
    "inLanguage": "en",
    "license": "https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document",
    "datePublished": "2018-02-22",
    "copyrightHolder": {
      "name": "World Wide Web Consortium",
      "url": "https://www.w3.org/"
    },
    "discussionUrl": "https://github.com/w3c/some-API/issues/",
    "description": "Abstract \n bla bla",
    "editor": [
      {
        "type": "Person",
        "name": "Your Name",
        "url": "https://your-site.com"
      }
    ],
    "citation": [
      {
        "id": "https://berjon.com/",
        "type": "TechArticle",
        "name": "The Dahut Specification Example From the Higher Circle",
        "url": "https://berjon.com/"
      }
    ]
  }
</script>