nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
162 stars 68 forks source link

hreflang is only working with standard robots all value in database #1399

Closed OneDeviloper closed 5 months ago

OneDeviloper commented 6 months ago

Hello everybody,

Maybe we found a problem, maybe not..

Describe the bug

Let's say we have three sites: Site 1: about us (home->about us) Site 2: XX (home->xx) Site 3: YY (home->yy)

On site 2 and 3 (in a round about 250 sites big project) we found out, that we are not able to print out hreflangs. I did a check and found out, that here the "noindex" is preventing the hreflang to come out. The db has "robots":"noindex" at the metaGlobalVars inside the seomatic_metabundles. So it seems to be correctly at this point.

Result on Front-End: empty array for hreflangs: [] "seomatic.meta.mainEntityOfPage: WebSite" "seomatic.meta.robots: noindex"

In the entries of that sites in SEO-Tab I changed the option "Robots override" to true and tried to add the option "all".

Result on Front-End: still empty array for hreflangs: [] "seomatic.meta.mainEntityOfPage: WebSite" "seomatic.meta.robots: all"

And now we come to our problem. For site 1 we made the changes and voila, we can control the output of hreflangs ( related to some tests with both languages ).

Result on Front-End WITHOUT Robots override (standard db: "robots":"all"): filled hreflang = array:2 [▼] "mainEntityOfPage: WebPage" "robots: all"

Result on Front-End WITH Robots override to "noindex" (standard db: "robots":"all"): filled hreflang = array:1 [▼] (still one language, because I did the change for test only on one lang) "mainEntityOfPage: WebPage" "robots: noindex"

So I checked further and found here out, that the standard process is to get the values out of database. Now comes the, for me, curious thing: As I told the "robots":"noindex" is correctly inside the database with relating ids for the both buggy sites. And for the working site the standard in db is "robots":"all".

Expected behaviour

If I override it, I would expect, that I get hreflang, depending on what I put into the field, but it only works if the standard value in database is at "all".

Versions

Questions

When get's the info about robots stored in the database? How can I change it without manipulating directly in database? And is there a mistake by myself?

Thanks for reading. Hope everything is understandable

Abromeit commented 6 months ago

Same issue here. Thats a bug.

[Edit]

All instances of ...robots == are most likely wrong anyway. There are 2 matches in DynamicMeta.php , linked by @OneDeviloper. I suggest redoing the affected lines when patching the issue.

khalwat commented 5 months ago

So forgive me, but I'm not sure I clearly understand the issue that's being described here by either of you.

Do you have the sites set up in appropriate site groups as described here:

https://nystudio107.com/docs/seomatic/technologies.html#multi-site-language-locale-support

?

khalwat commented 5 months ago

@Abromeit can you explain to me what you mean by this:

All instances of ...robots == are most likely wrong anyway. There are 2 matches in DynamicMeta.php , linked by @OneDeviloper. I suggest redoing the affected lines when patching the issue.

Why do you believe that this line is incorrect? https://github.com/nystudio107/craft-seomatic/blob/develop-v4/src/helpers/DynamicMeta.php#L565

Abromeit commented 5 months ago

@khalwat Thank you for your patience - Let me have another go at it. Maybe with a little more detail this time ;)


Feedback on 1)

So i just created a fresh Craft installation.

Within, i created a new site-group and 2 sites for the languages:

a

Next, i added a section / channel "Pages".

Under "Content SEO > Pages" i changed "Robots" from "all" to "noindex".

b

Lets add some pages. Some with the inherited / default setting of "noindex" and one where we want to override this default and indeed have the page indexed in search engines:

c

Also notice that the pages shown above are created in both of our languages.

Now lets open the "indexable page" entry and configure the override:

d

At this point we successfully reproduced the error. I.e. hreflang Tags are missing on all pages, including the indexable one:

g

Whereas when we switch things up, so that the channel default is "robots=all" and we set only the posts that we don't want indexed to "noindex" - everything works just fine. I.e. our indexable page has hreflang Tags:

i



Feedback on 2)

The robots property can contain multiple values. So i think (but am not sure) that $metaBundle->metaGlobalVars->robots === 'none' from https://github.com/nystudio107/craft-seomatic/blob/develop-v4/src/helpers/DynamicMeta.php#L564-L567 might fail in all cases where the user selected multiple values.

j


We've had this in https://github.com/nystudio107/craft-seomatic/issues/1378


khalwat commented 5 months ago

Thanks, that last post is much more clear, and I think it gives me a path forward to reproduce and fix this issue.

I have not forgotten about this, it's on the list for the next update to SEOmatic.

I've been working on porting SEOmatic to Craft 5, which is now done. Thanks for your patience. https://github.com/nystudio107/craft-seomatic/releases/tag/5.0.0-beta.2

khalwat commented 5 months ago

2) The robots property can contain multiple values. So i think (but am not sure) that $metaBundle->metaGlobalVars->robots === 'none' from https://github.com/nystudio107/craft-seomatic/blob/develop-v4/src/helpers/DynamicMeta.php#L564-L567 might fail in all cases where the user selected multiple values.

@Abromeit thanks for that, pushed a fix for this, and you were exactly correct. It's a place I forgot to refactor when the value in the robots tag transitioned to being a comma-delimited list of values.

Going to look into the initial issue shortly.

khalwat commented 5 months ago

This is fixed.

Craft CMS 3:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop as 3.4.70”,

Then do a composer clear-cache && composer update

…..

Craft CMS 4:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v4 as 4.0.39”,

Then do a composer clear-cache && composer update

…..

Craft CMS 5:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v5 as 5.0.0-beta.3”,

Then do a composer clear-cache && composer update