Schema.org - JSON-LD - Where to Place?

后端 未结 3 1237
醉酒成梦
醉酒成梦 2020-11-27 15:31

I am looking to use JSON-LD for schema on a website. (Schema meaning schema.org data.) I know how to write the data but my question is is there a prefered location in my cod

3条回答
  •  情书的邮戳
    2020-11-27 16:15

    From the perspectives of Schema.org, JSON-LD, and the possibly extracted RDF, it should not matter. The data is the same, no matter from where in the document it got extracted.

    From the perspective of HTML5:

    If it’s data about your page (or what this page is about), you could place the script element in the head, as the head element

    […] represents a collection of metadata for the Document

    But of course it would not be wrong to use body for this instead. It’s just that you shouldn’t use head for data that is not about your page or what it represents.

提交回复
热议问题