Yoast / Yoast-SEO-for-TYPO3

Yoast SEO plugin for TYPO3
Other
51 stars 56 forks source link

h1 duplicate error, but nothing in source code #530

Open aschmutt opened 1 year ago

aschmutt commented 1 year ago

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

aschmutt commented 1 year ago

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

vnc-kber commented 1 year ago

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

fgerards commented 1 year ago

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

vnc-jboe commented 1 year ago

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

saitho commented 11 months ago

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.

helsner commented 9 months ago

same issue for us on latest state/version

georgringer commented 3 months ago

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);
    }

}