Yoast/Yoast-SEO-for-TYPO3

h1 duplicate error, but nothing in source code

aschmutt opened this issue · 7 comments

  • [ x] I've read and understood the contribution guidelines.
  • [ x] I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

In Backend I click on "SEO needs improvement" and I get the H1 duplicate warning. But on the page, there is just one H1 as it should be:
https://www.leuphana.de/studium.html

Single title: H1s should only be used as your main title. Find all H1s in your text that aren't your main title and change them to a lower heading level!

Please describe what you expected to happen and why.

The H1 warning shall only be displayed, if more than one H1 in source code

How can we reproduce this behavior?

  1. Go to https://www.leuphana.de/studium.html
  2. Check Source Code for h1 => there is just one
  3. In Backend I can see the H1 warning in the SEO block

Screenshots

Bildschirmfoto 2023-04-05 um 00 02 40

Additional context

Is there maybe some kind of caching involved, so the result is not updated?

Technical info

  • TYPO3 version: 10.4
  • Yoast SEO version: yoast_seo_premium 5.1.1
  • Relevant extensions in case of a bug:

We updated to yoast_seo_premium 5.3.0 on a dev server, the bug is still the same

Any update to this problem? We face it in all our typo3 systems as well.

for me, this false positive is solved with the yoast_seo v9.0.0

Updated to yoast_seo 9.0.1 and the problem still exists on all typo3 systems

saitho commented

We also have this issue. It happens when there is content before the first h1.
In our case it's a breadcrumb navigation. But also empty <a> tags seem to be a problem, i.e. the <a id="c123"></a> jumpmarks of TYPO3 content elements.

I moved the marker after the headline, and the breadcrumb navigation below the content and moved it up via CSS.
The first is fine, the latter is not, as this works against the principles of designing HTML pages.

I'd love to provide a fix for this, but I have no clue how to compile JS sources in this project.

same issue for us on latest state/version

thanks a lot for the hint. I am xclassing the previewservice and move everything before the h1 to the end. this might not fit for you but maybe gives you an idea

<?php

declare(strict_types=1);

namespace StudioMitte\Theme\XClass\YoastSeo;

use YoastSeoForTypo3\YoastSeo\Service\PreviewService;

class XclassedPreviewService extends PreviewService {


    protected function prepareBody(string $body): string
    {
        $body = parent::prepareBody($body);

        $pos = strpos($body, '<h1');
        if ($pos !== false) {
            $firstPart = substr($body, 0, $pos);
            $body = substr($body, $pos) . $firstPart;
        }
        return trim($body);
    }

}