User tests: Successful: Unsuccessful:
This PR fixes structured data errors that made Google flag breadcrumbs as invalid.
When a breadcrumb item was a menu heading, instead of a link, Google would flag it as an invalid breadcrumb because it did not have a link. This is fixed by removing the structured data markup from items without a link.
Create a site menu with a menu heading and subpages, like so:
Create a breadcrumbs module. Ensure the module is published and visible on Subpage 1.
Navigate to subpage 1.
Copy the URL and paste it into the field here: https://search.google.com/test/rich-results
View source of Subpage 1 and copy it into the code box on https://search.google.com/test/rich-results
(Alternatively, you can find the generated code for the ul and just copy that into the code box.)
Google detects the breadcrumbs but shows an error:
When you click on it to see more, this is the problem:
Google does not consider a breadcrumb item as valid unless it has a link. Since menu headings don't have links, we have to remove the structured data from that item.
Google detects the breadcrumbs and marks them as valid:
None as far as I'm aware.
Status | New | ⇒ | Pending |
Category | ⇒ | Modules Front End |
Title |
|
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://www.example.com"
},
{
"@type": "ListItem",
"position": 2,
"name": "Category",
"item": ""
},
{
"@type": "ListItem",
"position": 3,
"name": "item",
"item": "https://www.example.com/category/page2"
}
]
}
well that's annoying because https://validator.schema.org/ says its perfectly valid
I know, Google seems to be applying their own standard for structured data as it applies to rich search results.
FILE: /********/src/modules/mod_breadcrumbs/tmpl/default.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
51 | ERROR | [x] Whitespace found at end of line
| | (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine)
58 | ERROR | [x] Whitespace found at end of line
| | (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine)
60 | ERROR | [x] Whitespace found at end of line
| | (Squiz.WhiteSpace.SuperfluousWhitespace.EndLine)
@crystalenka I've made review suggestions for the code style error which @brianteeman has mentioned in his previous comment. You can add them to a batch of suggestions and apply that with one click, or you can apply each of the suggestions separately with a direct click. I thought I do that to make it more comfortable for you.
Labels |
Added:
?
|
@crystalenka I've made review suggestions for the code style error which @brianteeman has mentioned in his previous comment. You can add them to a batch of suggestions and apply that with one click, or you can apply each of the suggestions separately with a direct click. I thought I do that to make it more comfortable for you.
Thank you!!
@brianteeman Regarding the last item: It is not touched by this PR, and the if condition before that elseif is also not touched, so there should not be any change for that. If my understanding is right about how breadcrumbs and how menu items of type "Heading" or "Separator" work (which both are the types which have no link), it cannot happen that the last item of breadcrumbs belongs to a menu item of these types because to such menu items there is no navigation. So the PR should be ok as it is, no need to add the same logic changes for the last item. Or am I missing something?
I can confirm that before this PR google structure data test reports an error and after this pr it does not report an error.
I note however that the code for joomla 4.1 in the breadcrumbs is completely different
I guess this needs to be closed and remade for 4.1 - the code in 4.1 for the breadcrumbs structured data is completely different
Yeah, I will be taking a look at 4.1 to see if I can fix it there too but hadn't had a chance yet. I'll just close this one.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-01-24 09:30:44 |
Closed_By | ⇒ | crystalenka |
This may need to be fixed in 4.1 as well with the JSON microdata based on #30727