spatie/schema-org

Incorrect value type @context

mst101 opened this issue · 3 comments

Google Search Console gives me the following error and therefore my rich text snippets are not being recognised:

Structured data with syntax errors detected
Invalid items are not eligible for Google Search's rich results.

This appears to be due to the https being stripped out of the value for @context:

According to Google, it should be "@context":"https://schema.org", ... however the package generates "@context":"\/\/schema.org", ...

Good luck trying to escape a colon within JSON. I tried, but failed :-(

Hey,

could you please add a full example of your failing code?
This will make it easier for me to debug what's going on.

Thanks for your offer to help, but I've managed to track down the culprit now. It only took me 3 days...

It turns out to be an issue with the TrimUrls middleware in a package I installed which is supposed to speed up Laravel:

renatomarinho/laravel-page-speed.

I have closed the issue as this is not your problem :-)

Just my 2cents: I would never trim URLs for page speed.
There was a similar issue https://github.com/spatie/laravel-export/issues/60 - there are so many special cases when trimming isn't good and I don't know how many relative links you have or how long your base URL is that it's a speed improvement to save some bytes!? 🤔😉