Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
OneDeviloper opened this issue Jan 5, 2024 · 7 comments
Closed
Labels

Comments

@OneDeviloper
Copy link

OneDeviloper commented Jan 5, 2024

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

  • Plugin version: SEOmatic 4.0.37
  • Craft version: Craft CMS Pro 4.5.13

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
Copy link

Abromeit commented Jan 6, 2024

Same issue here. Thats a bug.

  • Default for channel 'robots=noindex'
  • Set 'robots=all' in 1 entry itself. (Override default)
  • hreflangs do not show up in frontend for that entry

[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
Copy link
Collaborator

khalwat commented Jan 11, 2024

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
Copy link
Collaborator

khalwat commented Jan 11, 2024

@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
Copy link

@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 #1378


@khalwat
Copy link
Collaborator

khalwat commented Jan 24, 2024

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 added a commit that referenced this issue Jan 25, 2024
…ount that `robots` can be a comma delimited list of values now ([#1399](#1399))
khalwat added a commit that referenced this issue Jan 25, 2024
…ount that `robots` can be a comma delimited list of values now ([#1399](#1399))
khalwat added a commit that referenced this issue Jan 25, 2024
…ount that `robots` can be a comma delimited list of values now ([#1399](#1399))
@khalwat
Copy link
Collaborator

khalwat commented Jan 25, 2024

  1. 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 added a commit that referenced this issue Jan 25, 2024
…n the Content SEO settings make it impossible to override the `robots` setting in an SEO Settings field ([#1399](#1399))
khalwat added a commit that referenced this issue Jan 25, 2024
…n the Content SEO settings make it impossible to override the `robots` setting in an SEO Settings field ([#1399](#1399))
khalwat added a commit that referenced this issue Jan 25, 2024
…n the Content SEO settings make it impossible to override the `robots` setting in an SEO Settings field ([#1399](#1399))
@khalwat
Copy link
Collaborator

khalwat commented Jan 25, 2024

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

@khalwat khalwat closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants