Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi,

It is pretty easy to implement any Json-LD with Couch.

Except that I try to do it for breadcrumbs, but I don't even know where to start.
How does it work? I mean, how do I retrieve the tree, or path, details?

It is for my print shop https://poppins-shop.com/shop/ but it would be useful for websites blog too.

Thanks for any help,
Paolo

A Json-LD for breadcrumbs looks like that:
Example from Google:
Code: Select all
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [{
    "@type": "ListItem",
    "position": 1,
    "item": {
      "@id": "https://example.com/books",
      "name": "Books",
      "image": "http://example.com/images/icon-book.png"
    }
  },{
    "@type": "ListItem",
    "position": 2,
    "item": {
      "@id": "https://example.com/books/authors",
      "name": "Authors",
      "image": "http://example.com/images/icon-author.png"
    }
  },{
    "@type": "ListItem",
    "position": 3,
    "item": {
      "@id": "https://example.com/books/authors/annleckie",
      "name": "Ann Leckie",
      "image": "http://example.com/images/author-leckie-ann.png"
    }
  },{
    "@type": "ListItem",
    "position": 4,
    "item": {
      "@id": "https://example.com/books/authors/ancillaryjustice",
      "name": "Ancillary Justice",
      "image": "http://example.com/images/cover-ancillary-justice.png"
    }
  }]
}
</script>
Ok, I got it.

It works, just have to find a way to use the counter tag, but I don't remember where is the doc. Anybody?
It doesn't register as an error for Json-LD rich results, but I'd prefer it to be neat.

Code: Select all
<script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "BreadcrumbList",
      "itemListElement": [
<cms:if k_is_page || k_is_folder >
    {
        "@type": "ListItem",
        "position": 1,
        "name": "<cms:show k_template_title/>",
        "item": "<cms:show k_template_link/>"
      }
    <cms:if k_folder_name ><cms:set my_folder=k_folder_name /></cms:if>
    <cms:if k_page_foldername ><cms:set my_folder=k_page_foldername /></cms:if>
    <cms:if my_folder >
        <cms:parentfolders folder=my_folder >     
     
      ,{
        "@type": "ListItem",
        "position": 2,
        "name": "<cms:show k_folder_title/>",
        "item": "<cms:show k_folder_link/>"
      }
    </cms:parentfolders>
    </cms:if>
</cms:if>
<cms:if k_is_page>
     ,{
        "@type": "ListItem",
        "position": 3,
        "name": "<cms:show k_page_title/>",
        "item": "<cms:show k_page_link/>"
      }
</cms:if>   
      ]
    }
</script>
Final code, should work everywhere. [Updated April 2024]

Code: Select all
<cms:if k_is_home!='1'>
<cms:set poscount='1' />
<script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "BreadcrumbList",
      "itemListElement": [
<cms:if k_is_page || k_is_folder >
    {
        "@type": "ListItem",
        "position": <cms:show poscount /><cms:incr poscount '1' />,
        "name": "<cms:show k_template_title/>",
        "item": "<cms:show k_template_link/>"
      }
    <cms:if k_folder_name ><cms:set my_folder=k_folder_name /></cms:if>
    <cms:if k_page_foldername ><cms:set my_folder=k_page_foldername /></cms:if>
    <cms:if my_folder >
        <cms:parentfolders folder=my_folder >     
     
      ,{
        "@type": "ListItem",
        "position": <cms:show poscount /><cms:incr poscount '1' />,
        "name": "<cms:show k_folder_title/>",
        "item": "<cms:show k_folder_link/>"
      }
    </cms:parentfolders>
    </cms:if>
</cms:if>
<cms:if k_is_page>
     ,{
        "@type": "ListItem",
        "position": <cms:show poscount />,
        "name": "<cms:show k_page_title/>",
        "item": "<cms:show k_page_link/>"
      }
</cms:if>   
      ]
    }
</script>
</cms:if>
3 posts Page 1 of 1
cron