Where do I put Google's JSON-LD structured data?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:27:07

问题


I am trying to create Googles structured data no clue what I am doing. I set it up as an Organization then used the SD markup tool for all my products. I put each JSON-LD product inside it's own script tag directly from the markup tool vs. nesting. Then I put this in a .js file on my server. I linked it in my header with this

<script src="../Scripts/structureddata.js"></script>

I had tested it in the SD tool using the url and it didn't see it. Then I copied the structureddata.js into the tool, it say that so then I corrected any warnings and errors it showed my 50 products. Tried again and it does not see it from the url. I can see it inside the Search Console it shows 1 item. I am "assuming" from reading it only shows one...?

Can anyone help me with this. Should I have put it in a .js file? Can I use a link to a .js file? Why won't the SD tool see the structured data from my linked file?


回答1:


You have to include the JSON-LD in a script element used as data block:

<script type="application/ld+json">
  {
   "@context": "http://schema.org",
   "@type": "Thing"
  }
</script>

You can place this script element in the head or somewhere in the body.

Google doesn’t seem to support JSON-LD in external files. For their search features, they currently only support JSON-LD (as in the example above), Microdata, and RDFa.



来源:https://stackoverflow.com/questions/39000408/where-do-i-put-googles-json-ld-structured-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!