How to markup the last non linking item in breadcrumbs list using JSON-LD
Asked Answered
B

3

9

I am using structured data for my breadcrumbs trail. I'm refering to this documentation:

https://developers.google.com/structured-data/breadcrumbs

I have built up a breadcrumbs list. I also display the last item that refers to the current page but this is not a link but just plain text. This is what my HTML markup looks like:

<ol class="breadcrumb">
     <li><a href="http://www.example.com/">Home</a></li>
     <li><a href="http://www.example.com/brands">Brands</a></li>
     <li class="active">My Brand</li>
</ol>

I have opted to use JSON-LD to markup my breadcrumbs trail. I'm not sure how to markup the last item in my breadcrumbs list seeing that it is not a link? Am I supposed to leave it out? This is what I currently have:

<script type="application/ld+json">
{
     "@context": "http://schema.org",
     "@type": "BreadcrumbList",
     "itemListElement": [{
          "@type": "ListItem",
          "position": 1,
          "item": {
               "@id": "http://www.example.com/",
               "name": "Home"
          }
     }, {
          "@type": "ListItem",
          "position": 2,
          "item": {
               "@id": "http://www.example.com/brands",
               "name": "Brands"
          }
     }]
}
</script>

Do I need to add the last item like I did with the other 2 items, or do I need to leave it? Is it just for the items that have links to it?

British answered 13/11, 2015 at 8:34 Comment(0)
V
13

Of course you can simply provide the ListItem for the last item and omit the @id:

<script type="application/ld+json">
{
     "@context": "http://schema.org",
     "@type": "BreadcrumbList",
     "itemListElement": [{
          "@type": "ListItem",
          "position": 1,
          "item": {
               "@id": "http://www.example.com/",
               "name": "Home"
          }
     }, {
          "@type": "ListItem",
          "position": 2,
          "item": {
               "@id": "http://www.example.com/brands",
               "name": "Brands"
          }
     }, {
          "@type": "ListItem",
          "position": 3,
          "item": {
               "name": "My Brand"
          }
     }]
}
</script>

That is valid JSON-LD and fine according to Schema.org.

However, I would add the URL of the last/current item anyway. In case of RDFa or Microdata, I would have used the link element for the last item’s URL (so the URL is not clickable for human visitors, but bots have more data), but in case of JSON-LD, this problem isn’t relevant in the first place, as the human visitors typically don’t interact with it.

The only conceivable downside could be that a consumer gets confused if the content in the HTML doesn’t match the content in JSON-LD (i.e., the URL for the last item is missing). But I’d consider this risk pretty low, as it should be well known that there are different ways how to handle the last breadcrumb item.


As far as documentation goes, Schema.org only says that the BreadcrumbList is "typically ending with the current page".

And as an example for a consumer, Google says the same for their Breadcrumbs feature:

The breadcrumb trail may include or omit a breadcrumb for the page on which it appears.

But they don’t say anything about the case where the last item is included without its URL.

Vibrate answered 13/11, 2015 at 11:29 Comment(7)
Adding the url to the last breadcrumb won't it appear in the trail in a Google search result?British
@BrendanVogt: I couldn’t imagine why it should appear. Google is fine with both variants (including or not including the last/current item), and my guess is that they handle these cases the same: not showing it in their SERP (because it would be redundant).Vibrate
Can you please supply some markup on your link element suggestion using microdata?British
@BrendanVogt: You’d just replace the last a element with a link element (here’s an example with a link element with itemprop in the body).Vibrate
Just another question regarding the JSON-LD code that you posted. Would you add the link of the last item here as well even though it is not "linkable"?British
@BrendanVogt: You mean if I would add @id for the last ListItem, too? Yes (as I wrote, However, I would add the URL of the last/current item anyway.)Vibrate
as from 19 Sept 2019 this is no longer valid. The section item of the last ListItem is not complete. twitter.com/googlewmc/status/1174693878835875840Dossier
M
0

i'm not a SEO expert or know exactly what is your goal, but reading the linked api is not specify if the link(@id) are mandatory in JSON-LD, but from the official documentation JSON-LD documentation seems that they can omitted but with possible not desiderable effects.

6.14 Identifying Blank Nodes

At times, it becomes necessary to be able to express information without being able to uniquely identify the node with an IRI. This type of node is called a blank node. JSON-LD does not require all nodes to be identified using @id. However, some graph topologies may require identifiers to be serializable. Graphs containing loops, e.g., cannot be serialized using embedding alone, @id must be used to connect the nodes. In these situations, one can use blank node identifiers, which look like IRIs using an underscore (_) as scheme. This allows one to reference the node locally within the document, but makes it impossible to reference the node from an external document. The blank node identifier is scoped to the document in which it is used.

in this case particular case i will leave blank the last item or try to add it and omits the url.

if you want to be sure about preview of the actual page (as in linked documentation) on the google search page, so that in the list of breadcrumb the cuttent page will appear, i suggest to add an hidden element in the ol with the link to the current page, and add it to the breadcumb JSON-LD list with the link.

<ol class="breadcrumb">
 <li><a href="http://www.example.com/">Home</a></li>
 <li><a href="http://www.example.com/brands">Brands</a></li>
 <li class="hidden"><a href="http://www.example.com/My_Brand">My Brand</a></li>
 <li class="active">My Brand</li>
</ol>
Mutualize answered 13/11, 2015 at 9:4 Comment(0)
I
0

<script type="application/ld+json">
{
     "@context": "http://schema.org",
     "@type": "BreadcrumbList",
     "itemListElement": [{
          "@type": "ListItem",
          "position": 1,
          "item": {
               "@id": "http://www.example.com/",
               "name": "Home"
          }
     }, {
          "@type": "ListItem",
          "position": 2,
          "item": {
               "@id": "http://www.example.com/brands",
               "name": "Brands"
          }
     }, {
          "@type": "ListItem",
          "position": 3,
          "item": {
          	"@id": "http://www.example.com/brands/mybrand",
               "name": "My Brand"
          }
     }]
}
</script>

The correct Jason-LD code is given here.

Although Unor says that his code is validated, please note that his code is not validated without the last item.id, in https://search.google.com/structured-data/testing-tool

Intromit answered 10/12, 2018 at 4:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.