? Pending

User tests: Successful: Unsuccessful:

avatar crystalenka
crystalenka
13 Jan 2022

Summary of Changes

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.

Testing Instructions

Create a site menu with a menu heading and subpages, like so:

  • Home
  • Menu Heading
    • Subpage 1

Create a breadcrumbs module. Ensure the module is published and visible on Subpage 1.

Navigate to subpage 1.

If this site is accessible over the internet:

Copy the URL and paste it into the field here: https://search.google.com/test/rich-results

If this site is hosted locally:

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

Actual result BEFORE applying this Pull Request

Google detects the breadcrumbs but shows an error:
Screenshot showing Google Rich Search results error details

When you click on it to see more, this is the problem:
Screenshot showing Google Rich Search results error details

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.

Expected result AFTER applying this Pull Request

Google detects the breadcrumbs and marks them as valid:
Screenshot showing Google Rich Search results with valid notification

Documentation Changes Required

None as far as I'm aware.

avatar crystalenka crystalenka - open - 13 Jan 2022
avatar crystalenka crystalenka - change - 13 Jan 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Jan 2022
Category Modules Front End
avatar crystalenka
crystalenka - comment - 13 Jan 2022

This may need to be fixed in 4.1 as well with the JSON microdata based on #30727

avatar crystalenka crystalenka - change - 13 Jan 2022
Title
[4.x] Fix Google Structured Data Errors in Breadcrumbs
[4.0] Fix Google Structured Data Errors in Breadcrumbs
avatar crystalenka crystalenka - edited - 13 Jan 2022
avatar brianteeman
brianteeman - comment - 13 Jan 2022
  1. Pretty sure the changes here are not correct as they remove the special handling for the last item (might need more coffee before checking 100%)
  2. with the JSON microdata it is valid to have the following. Note the item"" for the non-linked item

{
    "@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"
        }
    ]
}
avatar crystalenka
crystalenka - comment - 13 Jan 2022

I did not remove the special handling for the last item. It's untouched.

Also, Google does not accept blank urls in 'item'; it marks it as invalid. I tested your code with the link above, this is what it Google says:

Screen Shot 2022-01-13 at 10 34 03

avatar brianteeman
brianteeman - comment - 13 Jan 2022

well that's annoying because https://validator.schema.org/ says its perfectly valid

avatar crystalenka
crystalenka - comment - 13 Jan 2022

I know, Google seems to be applying their own standard for structured data as it applies to rich search results.

avatar brianteeman
brianteeman - comment - 13 Jan 2022
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)
avatar richard67
richard67 - comment - 13 Jan 2022

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

avatar crystalenka crystalenka - change - 13 Jan 2022
Labels Added: ?
avatar crystalenka
crystalenka - comment - 13 Jan 2022

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

avatar richard67
richard67 - comment - 13 Jan 2022

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

avatar brianteeman
brianteeman - comment - 13 Jan 2022

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

avatar brianteeman
brianteeman - comment - 24 Jan 2022

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

avatar crystalenka
crystalenka - comment - 24 Jan 2022

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.

avatar crystalenka crystalenka - change - 24 Jan 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-01-24 09:30:44
Closed_By crystalenka
avatar crystalenka crystalenka - close - 24 Jan 2022

Add a Comment

Login with GitHub to post a comment