contao / core-bundle

[READ-ONLY] Contao Core Bundle
GNU Lesser General Public License v3.0
123 stars 58 forks source link

Google showing the homepage link twice #1561

Closed ghost closed 5 years ago

ghost commented 6 years ago

Comment by @CMSworker June 11th, 2018, 21:56 GMT

Did somebody test this successfully in an active live installation?

In my case it didn't solve the problem of Google showing the homepage link twice. Still looking like this:

https://www.domain.de > Homepage > Subpage

instead of

https://www.domain.de > Subpage

I thougt the problem could possibly be the wrong id of the webpage, when the breadcrumbs are now a microdata child element of the whole page.

Like in your screenshot, right side, 2. line:

@id: https://.../top

The id "top" is set in line 28 in fe_page.html5 together with itemtype="http://schema.org/WebPage" :

<body id="top" class="...

Because of the anchor id there is a difference in the URL of the webpage element and the URL in the breadcrumb element. So probably machines see this as two different entities/webpages and the breadcrumb and page-id-url will never be identical?

I changed it for testing and added an explizit microdata itemid, so the url of the webpage-element is the same as within the breadcrumb link:

<body id="top" itemid="{{env::path}}{{env::request}}" class="...

Didn't work.

What are your findings?

leofeyer commented 5 years ago

@CMSworker @ausi What's the status of this issue?

CMSworker commented 5 years ago

This issue is Google related and can not be solved, as long as you are ignoring the fields that Google is defining as "required" in their documentation.

So no, currently there is no solution, because fix #1527 is not working for Google (see comment here) and #1421 (or #1429) are already closed without a solution that is interpreted correctly by Google.

leofeyer commented 5 years ago

The following changes in the mod_breadcrumb.html5 template fix the errors in the test tool:

 <?php $this->block('content'); ?>

   <ul itemprop="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
-    <?php foreach ($this->items as $item): ?>
+    <?php foreach ($this->items as $count => $item): ?>
       <?php if ($item['isActive']): ?>
-        <li class="active<?php if ($item['class']): ?> <?= $item['class'] ?><?php endif; ?> last" itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"><span itemprop="name"><?= $item['link'] ?></span></li>
+        <li class="active<?php if ($item['class']): ?> <?= $item['class'] ?><?php endif; ?> last"><?= $item['link'] ?></li>
       <?php else: ?>
-        <li<?php if ($item['class']): ?> class="<?= $item['class'] ?>"<?php endif; ?> itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"><a href="<?= $item['href'] ?>" title="<?= $item['title'] ?>" itemprop="url"><span itemprop="name"><?= $item['link'] ?></span></a></li>
+        <li<?php if ($item['class']): ?> class="<?= $item['class'] ?>"<?php endif; ?> itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement"><a href="<?= $item['href'] ?>" title="<?= $item['title'] ?>" itemprop="item"><span itemprop="name"><?= $item['link'] ?></span></a><meta itemprop="position" content="<?= $count + 1 ?>"></li>
       <?php endif; ?>
     <?php endforeach; ?>
   </ul>
leofeyer commented 5 years ago

Note that if $item['href'] is empty, we need to output / or ./ to prevent the "field item requires a value" error.

leofeyer commented 5 years ago

Fixed (hopefully for good) in contao/contao@23f005a8e7b964b155bc907b008eb9716e403df7.