Yoast / wordpress-seo

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

"Directory for default language" in WPML breaks Yoast Sitemap links #16757

Open Remiol opened 3 years ago

Remiol commented 3 years ago

Please give us a description of what happened.

When I enable Use directory for default language in WPML p.e. /fr/ and click on "See the XML sitemap" in yoast, the link is directed to the root directory but it gives an 404 error.

I noted that "sitemap_index.xml" is moved to the /fr/ directory, however all indexed sitemaps post-sitemap.xml / page-sitemap.xml etc are linked to the root directory (wp installation directory) They all give 404 errors.

Please describe what you expected to happen and why.

I aspect "sitemap_index.xml and indexed sitemaps (post-sitemap/page-sitemap etc) to be in the root (wp installation directory).

How can we reproduce this behavior?

I didn't want to try it on the live site to avoid google search penalties. I'm testing in on my local site.

Used versions

Djennez commented 3 years ago

@dgwatkins correct me if I'm wrong; the described behavior should not happen, right? If I check https://wpml.org/errata/yoast-seo-sitemaps-only-work-with-different-domains/, using languages in folders should consolidate all languages in one sitemap?

Remiol commented 3 years ago

@dgwatkins correct me if I'm wrong; the described behavior should not happen, right? If I check https://wpml.org/errata/yoast-seo-sitemaps-only-work-with-different-domains/, using languages in folders should consolidate all languages in one sitemap?

Yes, all languages should be in one sitemap. All languages are in one sitemap but in the wrong directory.

sitemap link in yeast point to: wp/sitemap_index.xml --> 404

The sitemap is in: wp/fr/sitemap_index.xml

In above sitemap,

wp/post-sitemap.xml wp/page-sitemap.xml etc are all pointing to the root. --> all 404

timocouckuyt commented 1 year ago

I can also simulate this issue with the following versions installed and the "directory for default language" option active in WPML:

Used versions

WordPress: Version 6.1.1 Yoast SEO: Version 19.12 WPML Multilingual CMS: 4.5.14 WPML SEO: Version 2.1.0 WPML String Translation: Version 3.2.3

Having a site with 3 languages, /nl/, /fr/ and /en/:

Reverting Yoast SEO version to 14.4.1 solves the issue (last known version for the particular site we were upgrading):

I believe it has something to do with the way WPML is using the home_url filter, the behaviour has changed heavily in latest iterations of WPML. Taking a look at options-permalink.php in the WP back-end also shows the home_url filter logic of WPML is active at that time, which should not be the case, but it's a hint of why root queries to the sitemaps are also effected:

image

// T

timocouckuyt commented 1 year ago

My last post can be ignored, clearing the Yoast transient cache solved the issue for me here, using the above versions of plugins.