Page 2 of 2

Re: Google Search Console errors

Posted: Sun Jul 12, 2020 7:38 pm
by Michael_G
Hello, everybody,

the topic is already older, but unfortunately still not really solved.
If you start new with CMSimple_XH and want to use Google's Rich Snippets, you have to find this thread and then try the suggestions, otherwise you won't get anything with Rich Snippets and some websites will be added to the index slower than if they do everything right.

olape's last post was the only working, though not perfect, solution for my websites (thanks!).
The "items" still remain empty and they are "things", that would perhaps be nicer, unless it belongs that way. ;)

Below you find the result for the test of the web page https://domainname.tld/en/?glossary/p and it looks very good. :D

Code: Select all

BreadcrumbList 0 FEHLER 0 WARNUNGEN
@type	BreadcrumbList

itemListElement	
@type	ListItem
name	Home
position	1
item	
@type	Thing
@id	https://domainname.tld/en/?home

itemListElement	
@type	ListItem
name	Glossary
position	2
item	
@type	Thing
@id	https://domainname.tld/en/?glossary

itemListElement	
@type	ListItem
name	P
position	3
Thanks to the code of olape a post above mine: it replaces the previous code in the file tplfuncs.php:

Code: Select all

function locator()
{
    $breadcrumbs = XH_getLocatorModel();
    $last = count($breadcrumbs) - 1;
	$html = '<span itemscope itemtype="https://schema.org/BreadcrumbList">';
    foreach ($breadcrumbs as $i => $breadcrumb) {
        list($title, $url) = $breadcrumb;
        if ($i > 0) {
            $html .= ' &gt; ';
        }
		$html .= '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">';
		$inner = '<span itemprop="name">' . $title
			. '</span>';
        if (isset($url) && $i < $last) {
			$html .= '<a itemprop="item" href="' . $url . '">'
                . $inner . '</a>';
        } else {
			$html .= $inner;
        }
		$html .= '<meta itemprop="position" content="'. ($i + 1) . '"></span>';
    }
    $html .= '</span>';
    return $html;
}

Re: Google Search Console errors

Posted: Sun Jul 12, 2020 9:00 pm
by Michael_G
Addendum:
The "item" field is for the URL.

Syntax found with the great online tool
https://technicalseo.com/tools/schema-markup-generator/