Google Search Console errors

General questions about CMSimple
Post Reply
bca
Posts: 293
Joined: Tue Sep 15, 2009 4:49 pm

Google Search Console errors

Post by bca » Fri Sep 20, 2019 12:46 pm

In the last couple of days I have been receiving Search Console error reports on all my CMSimple sites( except 1)
It says "Fix Breadcrumbs Markup"
I dont receive the error on a site that is at 1.6.7 but on all sites with 1.7.2

I have looked at the generated locator code in the Google Structured Data testing Tool and it throws up errors.
position: A value for the position field is required
and
item: A value for the item field is required

Looking at the code it seems there is a </a> in the wrong place (moving it fixes the position error)
and on the last item in a list the <a property="item" typeof="WebPage" href="XXX"> is missing altogether.

I assume the error is in function locator()

B

designfjord
Posts: 63
Joined: Fri Apr 16, 2010 4:19 pm
Location: Germany/Franconia

Re: Google Search Console errors

Post by designfjord » Sun Sep 22, 2019 7:10 pm

"me too" !
The "error" is function locator.

Is there a solution?

Thanks in advance
Jochen
XH 1.4, XH 1.5, RealBlog1.5 | OS: XP Win7 Ubuntu | keep it simple

lck
Posts: 1699
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Google Search Console errors

Post by lck » Mon Sep 23, 2019 12:07 pm

bca wrote:
Fri Sep 20, 2019 12:46 pm
Looking at the code it seems there is a </a> in the wrong place (moving it fixes the position error)
and on the last item in a list the <a property="item" typeof="WebPage" href="XXX"> is missing altogether.

I assume the error is in function locator()
This seems to be the case in tplfuncs.php (Example-Page of the mentioned errors).

The </a> tag should be moved and inserted before <meta property="position" content="...>.
And also the last entry in the breadcrumb navigation must be linked to fix all errors.
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

bca
Posts: 293
Joined: Tue Sep 15, 2009 4:49 pm

Re: Google Search Console errors

Post by bca » Tue Sep 24, 2019 2:26 pm

After a bit of experimentation this seems to work.I hope its valid

Code: Select all

function locator()
{
    $breadcrumbs = XH_getLocatorModel();
    $last = count($breadcrumbs);
    $html = '<span vocab="http://schema.org/" typeof="BreadcrumbList">';
    foreach ($breadcrumbs as $i => $breadcrumb) {
        list($title, $url) = $breadcrumb;
        if ($i > 0) {
            $html .= ' &gt; ';
        }
        $html .= '<span property="itemListElement" typeof="ListItem">';
        $inner = '<span property="name">' . $title
            . '</span></a><meta property="position" content="'. ($i + 1) . '">';
        if (isset($url) && $i < $last) {
            $html .= '<a property="item" typeof="WebPage" href="' . $url . '">'
                . $inner . '</a>';
        } else {
            $html .= $inner;
        }
        $html .= '</span>';
    }
    $html .= '</span>';
    return $html;
}
Ive put the <\a> in at line 11 and taken out the -1 at line 2. You get a link on every breadcrumb including the last one.
There is some code in there which doesnt need to be there but not great at coding so not sure what does what. :lol: :cry:

B

cmb
Posts: 13273
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Google Search Console errors

Post by cmb » Wed Sep 25, 2019 9:50 pm

bca wrote:
Fri Sep 20, 2019 12:46 pm
Looking at the code it seems there is a </a> in the wrong place (moving it fixes the position error)
Indeed. For some reason I missed that `position` is meant to be a sibling of `item`, but not a child of it.
bca wrote:
Fri Sep 20, 2019 12:46 pm
and on the last item in a list the <a property="item" typeof="WebPage" href="XXX"> is missing altogether.
Well, actually linking to the page you're already on is something we didn't intend to do. Of course, this could be changed, but it seems to me that Google might not need an actual link, but a <span> would also do.

So tentatively, I suggest this patch. The testing tool appears to be satisfied with that.

PS: fun stuff (or maybe not so funny – could have had already been fixed).
Christoph M. Becker – Plugins for CMSimple_XH

bca
Posts: 293
Joined: Tue Sep 15, 2009 4:49 pm

Re: Google Search Console errors

Post by bca » Thu Oct 03, 2019 9:04 am

That worked thanks

Just heard from google that all is well. :roll:

Brett

Post Reply