简体   繁体   English

如何将 JSON-LD 面包屑模式添加到我的网站导航以用于 SEO 目的

[英]How to add JSON-LD breadcrumbs schema to my website navigation for SEO purposes

Edit: My understanding of the issue improved as I was writing the question, but I still haven't cleared everything out, that's why I am still asking:编辑:当我写这个问题时,我对这个问题的理解有所提高,但我仍然没有清除所有内容,这就是为什么我仍然在问:

I got introduced to breadcrumbs today and I am still not quite sure I understand them correctly (and I would be really thankful to anyone that helps me understand this better).我今天被介绍给面包屑,但我仍然不太确定我是否正确理解它们(我会非常感谢任何帮助我更好地理解这一点的人)。

I am interested in the SEO part of breadcrumbs: I don't want them displayed anywhere on my website.我对面包屑的 SEO 部分感兴趣:我不希望它们显示在我网站的任何位置。 So I don't want something looking like this:所以我不想要这样的东西:

home > products > kids > pants

I already have a normal menu (example):我已经有一个普通菜单(示例):

_________________________________________________________________________________________________

   LOGO                     About us      Services      Products     Contact us
_________________________________________________________________________________________________

And each link on the above menu has sublinks.上面菜单上的每个链接都有子链接。 I only care that the SEO part of the breadcrumbs gets implemented in the already existing (above) menu.我只关心面包屑的 SEO 部分是否在已经存在的(上面)菜单中实现。 Am I making sense?我说得有道理吗?

If so, then how exactly should I implement it?如果是这样,那么我应该如何实施呢? I actually tried to follow the example at the bottom of this page: https://schema.org/BreadcrumbList -- the JASON-LD one.我实际上尝试遵循此页面底部的示例: https://schema.org/BreadcrumbList - JASON-LD 之一。 But they have a simple example as follows:但他们有一个简单的例子如下:

The HTML: HTML:

<ol>
  <li>
    <a href="https://example.com/dresses">Dresses</a>
  </li>
  <li>
    <a href="https://example.com/dresses/real">Real Dresses</a>
  </li>
</ol>

The JSON-LD: JSON-LD:

<script type="application/ld+json">
{
 "@context": "http://schema.org",
 "@type": "BreadcrumbList",
 "itemListElement":
 [
  {
   "@type": "ListItem",
   "position": 1,
   "item":
   {
    "@id": "https://example.com/dresses",
    "name": "Dresses"
    }
  },
  {
   "@type": "ListItem",
  "position": 2,
  "item":
   {
     "@id": "https://example.com/dresses/real",
     "name": "Real Dresses"
   }
  }
 ]
}
</script>

As I understand, the above only covers one 'path' in the hierarchy, which probably means I need to recreate the code for all possible paths?据我了解,以上仅涵盖层次结构中的一个“路径”,这可能意味着我需要为所有可能的路径重新创建代码? I tried to do that for a more complex made-up menu just to put it in this question:我试图为更复杂的自制菜单这样做,只是为了把它放在这个问题中:

The HTML (mine): HTML(我的):

<div class="main-navigation">
    <div class="logo"><a href="https://www.haveabiscuit-potter.com/">Have a Biscuit, Potter</a></div>
    <!--not a real website -->
    <div class="menu-links">
        <div class="dropdown">
            <a href="https://www.haveabiscuit-potter.com/about-us" class="droptitle">About Us</a>
            <div class="dropdown-content">
                <a href="https://www.haveabiscuit-potter.com/about-us/our-journey">Our Journey</a>
                <a href="https://www.haveabiscuit-potter.com/about-us/part-in-fandom">Our Part in the Fandom</a>
            </div>
        </div>
        <div class="dropdown">
            <a href="https://www.haveabiscuit-potter.com/discussion" class="droptitle">Discussion</a>
            <div class="dropdown-content">
                <a href="https://www.haveabiscuit-potter.com/discussion/harry-needs-biscuit">Why Harry Needs a Biscuit</a>
                <a href="https://www.haveabiscuit-potter.com/discussion/dumbledoor-still-good">Dumbledoor is still good: an Introduction</a>
                <a href="https://www.haveabiscuit-potter.com/discussion/luna-lovegood-revenclaw">Luna Lovegood: Always a Revenclaw</a>
            </div>
        </div>
        <div class="dropdown">
            <a href="https://www.haveabiscuit-potter.com/contact-us" class="droptitle">Contact Us</a>
        </div>

    </div>
</div>

The JSON-LD (mine) - this covers just like 3 links from the above menu. JSON-LD(我的)——这涵盖了上面菜单中的 3 个链接。 I am not even sure if this is remotely correct but here we go:我什至不确定这是否正确,但在这里我们 go:


<script type="application/ld+json">
    {
        "@context": "http://schema.org", //or should I change this to https://haveabiscuit-potter.com -?
        "@type": "BreadcrumbList",
               "itemListElement": [{
                "@type": "ListItem",
                "position": 1,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com",
                    "name": "Home"
                }
            },
            {
                "@type": "ListItem",
                "position": 2,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com/about-us",
                    "name": "About Us"
                }
            },
            {
                "@type": "ListItem",
                "position": 3,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com/about-us/our-journey",
                    "name": "Our Journey"
                }
            }
        ],
        "itemListElement": [{
                "@type": "ListItem",
                "position": 1,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com",
                    "name": "Home"
                }
            },
            {
                "@type": "ListItem",
                "position": 2,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com/about-us",
                    "name": "About Us"
                }
            },
            {
                "@type": "ListItem",
                "position": 3,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com/about-us/part-in-fandom",
                    "name": "Our Part in the Fandom"
                }
            }
        ],
        "itemListElement": [{
                "@type": "ListItem",
                "position": 1,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com",
                    "name": "Home"
                }
            },
            {
                "@type": "ListItem",
                "position": 2,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com/discussion",
                    "name": "Discussion"
                }
            },
            {
                "@type": "ListItem",
                "position": 3,
                "item": {
                    "@id": "https://www.haveabiscuit-potter.com/discussion/dumbledoor-still-good",
                    "name": "Dumbledoor is Still Good"
                }
            }
        ]
    }

</script>

//Is the above correct? //上面说的对吗?

Now we get to the part where my understanding improved: seeing that it is tiresome to write the code manually for each link, I googled "JSON-LD breadcrumb generator" - and I found one that makes things easier: https://technicalseo.com/tools/schema-markup-generator/现在我们到了我的理解有所提高的部分:看到为每个链接手动编写代码很烦人,我用谷歌搜索了“JSON-LD 面包屑生成器”——我找到了一个让事情变得更容易的方法: https://technicalseo。 com/工具/模式标记生成器/

However, I again get only one path in between the <script> tags.但是,我再次在<script>标记之间只获得了一条路径。 So is that how I should generate it?那是我应该如何生成它吗? Will the output be hundreds of <script> elements each covering only one path? output 会是数百个<script>元素,每个元素只覆盖一条路径吗? Or can I put them together like what I did above?或者我可以像上面那样把它们放在一起吗? And in either case, should I insert the enormous JSON-LD code to the footer of every page on my website?在这两种情况下,我是否应该将大量 JSON-LD 代码插入我网站上每个页面的页脚?

Really thankful that you have read this far, and I really appreciate any help.真的很感谢你读到这里,我真的很感激任何帮助。

I am answering my own question: the confusion lied in that I didn't know where to 'put' those breadcrumbs.我正在回答我自己的问题:困惑在于我不知道将这些面包屑“放”在哪里。 I thought they were related to the navigation, and that's why they should be present on all pages.我认为它们与导航有关,这就是为什么它们应该出现在所有页面上。

That is not correct, breadcrumbs are unique for each page (well I guess that's obvious but it didn't click for me at first).这是不正确的,每个页面的面包屑都是唯一的(我想这很明显,但起初并没有为我点击)。

Here is the code that made me realize it: https://search.google.com/structured-data/testing-tool?utm_campaign=devsite&utm_medium=jsonld&utm_source=breadcrumb这是让我意识到它的代码: https : //search.google.com/structured-data/testing-tool?utm_campaign=devsite&utm_medium=jsonld&utm_source=breadcrumb

So each page should have the breadcrumb JSON-LD code that is relevant to itself and to its position in the hierarchy of the website.因此,每个页面都应具有与其自身及其在网站层次结构中的位置相关的面包屑 JSON-LD 代码。 That's it.就是这样。 Now I am off to see how to bulk generate those breadcrumbs for all my website pages.现在我要去看看如何为我的所有网站页面批量生成这些面包屑。

Sorry to see no body cares about this question, but I do.很抱歉看到没有人关心这个问题,但我关心。 Recently, I added the breadcrumb using bootstrap 5 to my website, since the feeling to make it better striked me somehow.最近,我使用 bootstrap 5 将面包屑添加到我的网站,因为不知何故让我觉得让它变得更好。 In the beginning, I thought the bot might be smart enough to recognize the "visaul" breadcrumb in HTML, so I go with html implementation first.一开始,我认为机器人可能足够聪明,可以识别 HTML 中的“visaul”面包屑,所以我首先使用 go 和 html 实现。 However, the google rich result test failed to identify my breadcrumb.但是,谷歌富结果测试未能识别我的面包屑。 That's when I realized that only three structured data format are accepted by google: reference .那时我意识到 google 只接受三种结构化数据格式: reference

Wish your website a prosperous one!祝您的网站一帆风顺!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM