clickstorm / cs_seo

[clickstorm] SEO
Other
33 stars 49 forks source link

Meta robots should be by default at index,follow #320

Closed lucmuller closed 11 months ago

lucmuller commented 12 months ago

If a records which has no_index=0 or no_follow = 0 is displayed on a page which has no_index = 1 or no_follow = 1 then the meta robots it's not overriden.

This occurs because in file Classes\Hook\MetaTagGeneratorHook.php the generator is only set if the value of the record is no_index or no_follow.

I will provide a merge request to correct this.

mhirdes commented 11 months ago

Hey, I got a little panic by the description of your ticket. But on our pages we allways set the detail page to noindex in the page settings. So this page is not indexed and not listed in the sitemap.xml. But when this page has a record as parameter there is no noindex on the page. This pages should be indexed.

To set index,follow is not necessary. This is the default.

How do you set the noindex? Also in the page settings?

lucmuller commented 11 months ago

@mhirdes yes, I've tried to setup the index/no_index on the page to exclude the page without details parameter from the sitemap. But settings this results in having a no_index by default on our records who have the cs_seo IRRE for SEO options.

Did we set up something wrong in our installation ?

Here's how it goes for our installation. Page : image Record : image And in the frontend on the page with the detail of our record : image

lucmuller commented 11 months ago

imho, the problems is at line 75-77 from MetaTagGeneratorHook :

if ($noIndex === 'noindex' || $noFollow === 'nofollow') {
       $generators['robots'] = ['value' => implode(',', [$noIndex, $noFollow])];
}

the generator is addressed only if the value is no_index or no_follow, thus fallbacking to page configuration if not set. It should be either set by default to index,follow (my merge proposal) or adressed to the value of the record in all cases if the value is = 0 or 1 to index or no_index

but I might have missed something ?

lucmuller commented 11 months ago

Removing the condition on the lines above would also do the trick as the $noIndex $noFollow are setup with the record value :

$generators['robots'] = ['value' => implode(',', [$noIndex, $noFollow])];

Thus resulting in having the generator always setup with the record values.

mhirdes commented 11 months ago

I checked it again with a record, that has a SEO record. Also then I get no robots output on the page.

Which TYPO3 and cs_seo vesion do you use?

lucmuller commented 11 months ago

TYPO3 : 12.4.6 cs_seo : 8.1.0

mhirdes commented 11 months ago

MMhhh. I have TYPO3 12.4.8 and the main branch of cs_seo. But this should not make a difference. Can we maybe take a look together on your TYPO3? You can contact me on Slack.

lucmuller commented 11 months ago

Can we maybe take a look together on your TYPO3? => Nope, that won't make it ^^ If you consider that it should work out of the box, then something might be wrong on our side. We'll check, as I did'nt notice anything in the first place.

I'll come back to you !

lucmuller commented 11 months ago

Here's my typoscript setup for meta robots generation.

page.meta.robots.cObject = COA
page.meta.robots.cObject {
    10 = TEXT
    10 {
        value = index
        override = noindex
        override.if.isTrue.field = no_index
    }
    20 = TEXT
    20 {
        value = ,follow
        override = ,nofollow
        override.if.isTrue.field = no_follow
    }
}

If I remove it from my site config, then the meta robots is not rendered at all.

Do you use another kind of configuration to have a better handling of the overriding of the meta ?

Shouldn't this config be setup in cs_seo typoscript ? I do not find any configuration for page.meta.robots in your cs_seo typoscript config (nor for description or other common meta)

Should we add some configuration in the CsSeo Yaml configuration file for a correct handling of the meta robots ? I guess no. currently we only avec yaml config for our records to overrides and no meta robots specific configuration.

mhirdes commented 11 months ago

You don't need extra TypoScript. The core SEO extension handles the output for pages, the cs_seo for detail pages.

https://github.com/TYPO3-CMS/seo/blob/main/Classes/MetaTag/MetaTagGenerator.php#L119

Again, you don't need to set index,follow because this is the default.

lucmuller commented 11 months ago

Ok, so there's someting I get wrong about TYPO3 and metadata in it's latest version.

As far as I know, typoscript config must be set in order to produce metadata : https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Setup/Page/Index.html#meta

value is the content of the meta tag. If the value is empty (after trimming), the meta tag is not generated. [...] the meta tag generated by the plugin will be used. If there is none yet, the one from TypoScript is set.

What I understand is the following :

Cs-seo do not place any content for meta robots if robots AND follow are at 0 in the record. Then fallback to typoscript config which use, in my case the values of the page.

Would you mind giving me the triggering configuration which should generate metadata without typoscript config ? Or maybe would you give me the typoscript config you're using for robots metatag ?

mhirdes commented 11 months ago

You don't need extra TypoScript. The core SEO extension handles the output for pages, the cs_seo for detail pages.

https://github.com/TYPO3-CMS/seo/blob/main/Classes/MetaTag/MetaTagGenerator.php#L119

lucmuller commented 11 months ago

Ok ! I've got the point. My problem is that i us an override that is no longer useful.

override = noindex override.if.isTrue.field = no_index

Thanks a lot.

By the way, you still need to register the meta robots to a default value

page.meta.robots = index,follow

Even bootstrap package sets it with a constants https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TypoScript/setup.typoscript#L307