标签: json-ld

附加链接搜索框JSON-LD在Google结构化数据测试工具上出错

我在我的网站上实施了Google的附加链接搜索框.它工作得很好.但是今天我再次对Google结构化数据测试工具进行了抨击,出了点问题.现在我收到以下错误:

Google结构化数据测试工具:WebSite的2个错误

我的实施是:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://www.saatler.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://www.saatler.com/arama?ara={search_term_string}",
    "query-input":"required name=search_term_string"
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

当我在JSON-LD操场上检查JSON时,一切都很好看.我没有更改我网站上的任何内容.谷歌在这个问题上是错的吗?或者Schema.org结构发生了变化?我该怎么做才能解决这两个问题?

schema.org json-ld google-rich-snippets

10
推荐指数
2
解决办法
2490
查看次数

如何在需要等待内容加载的动态页面上使用JSON-LD添加结构化数据?

我正在开发一个网站,我想将结构化数据添加到详细页面.问题是我需要在知道要添加到JSON-LD脚本的内容之前请求数据.

我使用Parse作为后端.我还试图寻找有关如何实现这一目标的教程,但似乎无法动态添加JSON-LD.

我真的希望有人可以帮助我!:)

编辑:

在DOM准备好之后,我需要在JSON-LD中添加数据的响应.这种情况下的模式是什么?

我有一个项目列表,当点击其中一个项目时,我必须打开一个我必须先加载的详细信息页面,但是在加载内容之后我想通过JSON-LD提供结构化数据.

我刚开始,我很难解决这个问题.

编辑2:

这是我的实际实现:

在HTML中:

<body>
    // my html page code
    ...
    <script type="text/javascript">
        loadDetailPageContent();
    </script>
</body>
Run Code Online (Sandbox Code Playgroud)

在JS中:

function loadDetailPageContent() {
    // Calling the method here is too early because I don't have info
    //writeData();
    createDetailPage();
}

function createDetailPage() {
    var recipe = Parse.Object.extend("Recipe");
    var query = new Parse.Query(recipe);
    query.equalTo("objectId", myId);
    query.first({
        success: function(result) {
            // Calling the method here would be perfect
            writeData();
        },
        error: function(error) {
            alert("Error: " + error.code + " " …
Run Code Online (Sandbox Code Playgroud)

json structured-data parse-platform json-ld

10
推荐指数
1
解决办法
6335
查看次数

在JSON-LD中,是否可以为属性值定义URI映射?

假设我们有以下JSON:

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": "http://schema.org/status"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}
Run Code Online (Sandbox Code Playgroud)

(JSON-LD游乐场)

trollin'状态被标识一个URI: http://example.com/trolling.是否可以将trollin'上面示例中的关键字扩展为URI http://example.com/trolling

直接操作上下文不起作用:

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": "http://schema.org/status",
    "trollin'": "http://example.com/trolling"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}
Run Code Online (Sandbox Code Playgroud)

(JSON游乐场)

强制的类型status@id也是不行的,因为它会假设trollin'是一个相对的URI.

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": {
      "@id": "http://schema.org/status",
      "@type": "@id"
    },
    "trollin'": "http://example.com/trolling"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}
Run Code Online (Sandbox Code Playgroud)

(JSON-LD游乐场)

json-ld

9
推荐指数
1
解决办法
450
查看次数

如何在rails 4 app中设置"application/ld + json"schema.org元数据

我想使用json ld设置schema.org元数据.例如,以下链接使用ghost并且它具有"application/ld + json"元数据. http://blog.ghost.org/distributed-team-tools/

我想为我的rails应用程序实现类似的功能.我应该如何实现它.这样做是否有一些宝石

谢谢!

ruby metadata schema.org ruby-on-rails-4 json-ld

9
推荐指数
1
解决办法
3528
查看次数

是否应该转义 JSON-LD 字符串?

JSON-LD 内容中的字符串值是否应该转义?例如,Google 建议使用以下内容为站点搜索提供提示:

<script type="application/ld+json">
{
   "@context": "http://schema.org",
   "@type": "WebSite",
   "url": "https://www.example-petstore.com/",
   "potentialAction": {
     "@type": "SearchAction",
     "target": "https://query.example-petstore.com/search?q={search_term_string}",
     "query-input": "required name=search_term_string"
   }
}
</script>
Run Code Online (Sandbox Code Playgroud)

但是,如果我网站的搜索 URL 包含多个查询参数怎么办?是否应该或可以转义目标值中的字符?例如:

"target": "https://query.example-petstore.com/search?foo=bar\u0026q={search_term_string}",
Run Code Online (Sandbox Code Playgroud)

在 JSON-LD 中进行标记时,同样的问题适用于几种常见的 schema.org 类型。Organization->sameAs 中的 Google+ 社交个人资料链接,例如:如果我的组织的个人资料是

https://plus.google.com/+BeardsAreSweet
Run Code Online (Sandbox Code Playgroud)

应该表示为:

"sameAs": ["https://plus.google.com/+BeardsAreSweet"]
Run Code Online (Sandbox Code Playgroud)

或者

"sameAs": ["https://plus.google.com/\u002bBeardsAreSweet"]
Run Code Online (Sandbox Code Playgroud)

更重要的是,这真的重要吗?

escaping schema.org json-ld

9
推荐指数
1
解决办法
2781
查看次数

JSON-LD缺少'}'或对象成员名称.错误

我想在之前将json-ld添加到我的网站,我想将它添加到我的开发站点进行测试

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "xxxxxxxxxxxxxxxx",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+xx-xxx-xxx-xxxx",
    "contactType": "customer service"

  }]
}
</script>
Run Code Online (Sandbox Code Playgroud)

我收到错误,指出Missing'}'或对象成员名称.什么是这个错误,我已正确关闭括号.如何修复它,请帮助

json json-ld

9
推荐指数
4
解决办法
1万
查看次数

Google SDTT中的错误:"为网址提供的所有值都必须指向同一页面."

我正在尝试为ecom网站上的产品列表创建一些JSON-LD结构化数据,但是在使用Google的结构化数据测试工具时出现错误.

到目前为止,我有这个:

 {
 "@context": "http://schema.org",
 "@type": "OfferCatalog",
 "name": "Fresh Fruit",
 "itemListElement": [
  {
   "@type": "ListItem",
   "position": 1,
   "item":
   {
        "@type": "Offer",
        "price": "1.20",
        "priceCurrency": "GBP",
        "availability": "http://schema.org/InStock",
        "url": "http://example.com/green-apples/",
        "itemOffered": {
            "@type": "Product",
            "name": "Green Apples",
            "url": "http://example.com/green-apples/"
            }
        }        
   }  
 ]
}
Run Code Online (Sandbox Code Playgroud)

大多数情况下它会验证,但Google工具会抛出以下错误:

为url提供的所有值必须指向同一页面.

错误突出显示第11行("@type": "Offer",).

URL字段似乎与@context声明冲突,因为如果我将上下文更改为非url字符串或者http://example.com,它会验证(尽管这显然会导致其自身的问题).(这已被证明是一个红鲱鱼,在下面的评论中)

我在这里错过了什么?感觉就像是一件非常明显的事情.

url schema.org json-ld google-rich-snippets

9
推荐指数
2
解决办法
5680
查看次数

获取vue-router的名称和params路由

我正在使用Vue与vue-router.对于列表视图中的产品项,我想生成JSON-LN注释,其url属性设置为产品详细信息视图的路径.

我知道我可以通过使用获得当前路线的路径,this.$route.path但有没有办法获得一个不同的路径路径,因为它将呈现

<router-link :to={name: 'ProductDetail', params: {id: some_id, slug: some_slug}}></router-link>

在其他地方注入路线的路径?

json-ld vue.js vue-router vuejs2

9
推荐指数
1
解决办法
1万
查看次数

如何使用python解析ld+json

我一直在尝试一些网页抓取,我在这个标签中发现了一些有趣的数据:

<script type="application/ld+json">
Run Code Online (Sandbox Code Playgroud)

我已经能够使用漂亮的汤来隔离那个标签

html = urlopen(url)
soup = BeautifulSoup(html, "lxml")

p = soup.find('script', {'type':'application/ld+json'})
print p
Run Code Online (Sandbox Code Playgroud)

但我无法处理数据或从该标签中提取任何数据。

如果我尝试使用正则表达式从中获取一些东西,我会得到:

TypeError: expected string or buffer
Run Code Online (Sandbox Code Playgroud)

如何从该脚本标记中获取数据并像使用字典或字符串一样使用它?顺便说一下,我正在使用 python 2.7。

python json web-scraping json-ld

9
推荐指数
2
解决办法
6344
查看次数

无论如何使用JSON-LD Schema没有内联

无论如何使用JSON-LD而不script在HTML中包含内联,但仍然可以让Google(和其他)蜘蛛找到它吗?环顾四周,我看到了一些相互矛盾的信息.

如果这是JSON-LD文件:

    <script type="application/ld+json">
    {
      "@context" : "http://schema.org",
      "@type" : "WebSite",
      "name" : "Example Site",
      "alternateName" : "example",
      "description" : "Welcome to this WebSite",
      "headline" : "Welcome to Website",
      "logo" : "https://example.com/public/images/logo.png",
      "url" : "https://example.com/"
    }
    </script>
Run Code Online (Sandbox Code Playgroud)

head在HTML中有这个:

<script src="/public/json-ld.json" type="application/ld+json"></script>
Run Code Online (Sandbox Code Playgroud)

编辑:我也尝试过:

<link href="/public/json-ld.json" rel="alternate" type="application/ld+" />
Run Code Online (Sandbox Code Playgroud)

谷歌蜘蛛似乎很想念它,测试工具也是如此,除非我直接指向该文件.我正在努力解决CSP中的不安全内联问题.我唯一能找到的就是这个,它可以在Chrome中运行,但不希望在每个其他浏览器上触发控制台错误.另外,我只是喜欢从页面结构中抽象出Schema.org数据的想法.将JSON-LD添加到Google网站站长工具的站点地图会有帮助吗?

道歉,JSON-lD的总菜单,并最终保留在电子邮件文档(这将是一个站点)或旧文档.

seo schema.org content-security-policy json-ld

8
推荐指数
1
解决办法
988
查看次数