Warm tip: This article is reproduced from serverfault.com, please click

html-如何出于SEO目的将JSON-LD面包屑架构添加到我的网站导航

(html - How to add JSON-LD breadcrumbs schema to my website navigation for SEO purposes)

发布于 2020-03-06 00:41:23

编辑:在撰写问题时,我对问题的理解有所提高,但是我仍然没有清除所有内容,这就是为什么我仍然在问:

我今天开始接触面包屑,但仍然不确定我是否正确理解面包屑(我真的要感谢能帮助我更好地理解面包屑的人)。

我对面包屑的SEO部分感兴趣:我不希望它们显示在我的网站上的任何位置。所以我不想要这样的东西:

home > products > kids > pants

我已经有一个普通菜单(示例):

_________________________________________________________________________________________________

   LOGO                     About us      Services      Products     Contact us
_________________________________________________________________________________________________

并且以上菜单上的每个链接都有子链接。我只关心面包屑的SEO部分在已经存在的菜单中实现。我有道理吗?

如果是这样,那我应该如何实施呢?我实际上想遵循此页面底部的示例:https ://schema.org/BreadcrumbList-JASON-LD。但是他们有一个简单的示例,如下所示:

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>

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>

据我了解,以上内容仅覆盖了层次结构中的一个“路径”,这可能意味着我需要为所有可能的路径重新创建代码吗?我想为一个更复杂的化妆菜单这样做,只是为了解决这个问题:

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>

JSON-LD(我的)-就像上面菜单中的3个链接一样。我什至不确定这是否是正确的,但是我们开始:


<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>

//以上是否正确?

现在,我们进入了我的理解得到改进的部分:看到为每个链接手动编写代码很烦人,我在“ JSON-LD面包屑生成器”上进行了搜索-我发现一个使事情变得更容易的方法:https:// technicalseo。 com / tools / schema-markup-generator /

但是,我再次在<script>标签之间只有一条路径那是我应该如何生成它?输出会是数百个<script>元素,每个元素仅覆盖一条路径吗?还是可以像上面一样将它们放在一起?无论哪种情况,我都应该在网站的每个页面的页脚中插入巨大的JSON-LD代码吗?

非常感谢你已经阅读了本文,非常感谢你的帮助。

Questioner
Ghadir
Viewed
11
Ghadir 2020-03-06 19:56:12

我在回答自己的问题:造成这种混乱的原因是,我不知道将那些面包屑放在哪里。我认为它们与导航有关,这就是为什么它们应该出现在所有页面上的原因。

这是不正确的,面包屑在每个页面上都是唯一的(嗯,我想这很明显,但起初并没有点击我)。

这是让我意识到的代码:https : //search.google.com/structured-data/testing-tool?utm_campaign=devsite&utm_medium=jsonld&utm_source=breadcrumb

因此,每个页面都应该具有与网站本身及其在网站层次结构中的位置相关的面包屑JSON-LD代码。就是这样。现在,我去看看如何为我的所有网站页面批量生成那些面包屑。