Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.76k stars 887 forks source link

Duplicated translated homepage on Yoast SEO sitemap #15189

Open rgllm opened 4 years ago

rgllm commented 4 years ago

Please give us a description of what happened.

I'm using WPML to manage the translations of some pages of a website. One of these pages is the homepage which is translated to de, pt-br, es and fr. I create the copies of the homepage from the English version, which originally had a slug. When I create and publish the translated pages they are duplicated on my sitemap (which is generated by Yoast SEO) as follows:

https://mywebsite.com/

https://mywebsite.com/de/
https://mywebsite.com/pt-br/
https://mywebsite.com/es/
https://mywebsite.com/fr/

https://mywebsite.com/de/original-slug-of-english-page
https://mywebsite.com/pt-br/original-slug-of-english-page
https://mywebsite.com/es/original-slug-of-english-page
https://mywebsite.com/fr/original-slug-of-english-page

Note: the https://mywebsite.com/original-slug-of-english-page is not on the sitemap.

I've read some similar reports, for example this one.

Please describe what you expected to happen and why.

The sitemap should only contain:

https://mywebsite.com/

https://mywebsite.com/de/
https://mywebsite.com/pt-br/
https://mywebsite.com/es/
https://mywebsite.com/fr/

Used versions

stodorovic commented 4 years ago

Yoast SEO Multilingual has integration code which includes all languages in SQL query. This plugin excludes all translated front pages via the filter _wpseo_exclude_from_sitemap_by_postids (to avoid duplicates). Some plugin or custom code may overrides results of this filter.

I'd like to see order of URLs (en home page should be first, somewhere in middle probably /../original-slug-of-english-page and translated home pages at the end). Could you make screenshot of page sitemap?

rgllm commented 4 years ago

Yoast SEO Multilingual has integration code which includes all languages in SQL query. This plugin excludes all translated front pages via the filter _wpseo_exclude_from_sitemap_by_postids (to avoid duplicates). Some plugin or custom code may overrides results of this filter.

I'd like to see order of URLs (en home page should be first, somewhere in middle probably /../original-slug-of-english-page and translated home pages at the end). Could you make screenshot of page sitemap?

Thank you @stodorovic.

I would prefer not to share a screenshot of the sitemap, but I will replicate here the order:

https://mywebsite.com/
https://mywebsite.com/de/original-slug-of-english-page
https://mywebsite.com/pt-br/original-slug-of-english-page
https://mywebsite.com/es/original-slug-of-english-page
https://mywebsite.com/fr/original-slug-of-english-page
https://mywebsite.com/de/
https://mywebsite.com/pt-br/
https://mywebsite.com/es/
https://mywebsite.com/fr/

Also, I can't use _wpseo_exclude_from_sitemap_by_postids since the duplicated pages have the same ID.

stodorovic commented 4 years ago

Based on you feedback, these pages are populated from main sitemap SQL query. WPML adds custom join/where which includes all languages (MySQL table _wp_icltranslations). I think that duplicated pages have different post IDs.

Yoast SEO Multilingual uses _wpseo_exclude_from_sitemap_by_postids (classes/class-wpml-wpseo-xml-sitemaps-filter.php) to exclude all translated pages. It's possible that 3rd plugin (or custom PHP code) breaks this filter. I've similar results when I remove this filter.

Other possibility is that relations in table wp_icl_translations aren't good, but you should see similar issues somewhere else.

If you have enough knowledge then it's possible to add PHP constants which turn on more debugging. You will see SQL query which you can run (eg. in phpMyAdmin) and see more details.

rgllm commented 4 years ago

Sorry for the long wait @stodorovic @dariaknl. I'll provide feedback once I get back to work on this.

Djennez commented 4 years ago

Is this issue still valid (with Yoast 14.3)?

rgllm commented 4 years ago

I haven't updated yet @Djennez, I will left here the feedback once I update. In the meantime I manually removed the links using a custom filter.

rgllm commented 4 years ago

I can confirm that it still happens on 14.3 @Djennez

githubyouser commented 4 months ago

@Djennez I am having exactly this same issue with Yoast (version 22.7) and WPML. Please can this be fixed? @rgllm how did you manually remove the links? Maybe I can do that in the meantime while we wait for an official fix.