如何实现JSON-LD? [英] How to implement JSON-LD?

查看:189
本文介绍了如何实现JSON-LD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天一直在阅读关于JSON-LD的内容,并且我理解它的目的,格式,并且我可以将它放在脚本标记中;然而,我不明白以下内容:


  1. 这个数据在哪里可以驻留,而不是在网站的脚本标记中?我一直在期待在任何脚本标记或包含.json文件中查找JSON-LD内容,当我查看说他们使用JSON-LD的网站的页面源时,但由于我没有看到任何这些内容,它导致我相信它必须可以在不同的位置访问。

  2. $
  3. 这些信息通常是为大型网站构建的吗? b $ b

  4. 其他网站如何找到JSON-LD文件,对象或数据来使用该信息?

  5. b $ b

    在野外看到一个例子真是太棒了。

    在HTML5中, href =http://www.w3.org/TR/2014/REC-html5-20141028/scripting-1.html#the-script-element =nofollow noreferrer> script 元素可以用作数据块:


    当用于包含数据块时脚本),数据必须嵌入内嵌,数据的格式必须使用类型属性中,不得指定 src 属性,并且脚本元素的内容必须符合定义的要求对于使用的格式。


    因此,包含JSON-LD的脚本元素可以看起来像这样:
    $ b

     < script type =application / ld + json> 
    {
    @context:http://example.com,
    @type:示例
    }
    < / script>

    可以将脚本元素放置在头部和/或 body


    I’ve been reading about JSON-LD today and I understand its purpose, format, and that I can put it in a script tag; however, I don’t understand the following:

    1. Where can this data reside other than in a script tag for a website? I've been expecting to find JSON-LD content in either script tags or included .json files when I view the page source of websites that say they use JSON-LD, but since I haven't seen any of this, it leads me to believe it must be accessible in a different location.

    2. How is this collection of information usually constructed for larger websites?

    3. How do other sites find the JSON-LD files, objects, or data to use that information?

    It would be really great to see an example in the wild.

    解决方案

    In HTML5, the script element can be used as data block:

    When used to include data blocks (as opposed to scripts), the data must be embedded inline, the format of the data must be given using the type attribute, the src attribute must not be specified, and the contents of the script element must conform to the requirements defined for the format used.

    So a script element containing JSON-LD could look like this:

    <script type="application/ld+json">
        {
         "@context": "http://example.com",
         "@type": "Example"
        }
    </script>
    

    You may place the script element(s) in the head and/or in the body.

    这篇关于如何实现JSON-LD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆