d13r / laravel-breadcrumbs

Please see the Diglactic fork.
https://github.com/diglactic/laravel-breadcrumbs
2.34k stars 416 forks source link

json-ld Unspecified Type #178

Closed MadMikeyB closed 6 years ago

MadMikeyB commented 6 years ago

Hello!

Love the package, use it on as many projects as I can.

First time using it solely for JSON-LD Schema though!

Everything works like a charm, but upon running the published site through Google's Structured Data Testing tool, I'm getting the following error:

Unspecified Type (The @type is required and cannot be an empty string.)

See Results

I'll preface the below with the fact that I'm not too familiar with schema.org - but it seems to me we're missing a @type declaration from each individual ListItem here:

https://github.com/davejamesmiller/laravel-breadcrumbs/blob/master/views/json-ld.php#L17

Though after looking at schema.org

Their example looks like this:

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

So I'm unsure what we can do here? Sorry for the rambling issue, I just wondered if there's anything you may know about this that I probably don't?

d13r commented 6 years ago

It looks like you have something in your app that's stripping the protocol:

{"@context":"\/\/schema.org",

Should be:

{"@context":"http:\/\/schema.org",

If you change that in the testing tool then it validates correctly.

MadMikeyB commented 6 years ago

Ahh! I'm noticing this with my canonicals as well.

Turns out the laravel-page-speed package does this with it's \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class middleware.

Thanks for the insight, sorry to bother, and thanks for not closing outright 👍