This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 6 replies, has 3 voices.

Last updated by timF-10 1 year, 7 months ago.

Assigned support staff: Ricardo Alday.

Author Posts
February 20, 2018 at 2:36 pm #1523740

Kaloyan

I am trying to:
Set custom canonical url with yoast and wpml is overwriting the domain name.
Link to a page where the issue can be seen:
hidden link
I expected to see:
<link rel="canonical" href="hidden link">
Instead, I got:
<link rel="canonical" href="hidden link">

I have disabled WPML and the canonical works well so the problem is not in Yoast.

February 21, 2018 at 4:50 pm #1525209

Ricardo Alday

Hi Mariana,

The canonical URL appears in the source code for a single post and usually, the standard setting is that the canonical points to itself, as it does correctly now on your post.
The canonical link in hidden link should also be hidden link

The purpose of the canonical URL is to point to the main URL for a page when there are other pages with similar content to prevent duplicate content issues.

The canonical URL is not supposed to point to other URLs that are different from the source URL.

When using URLs in directories, the URls of the different languages do not have that sort of relation to each other, so the canonical tag is not the best option to connect translations to each other. They are related by pointing each page to its translation with a <alternate> tag.

<link rel="alternate" hreflang="xx" href="....">

Using canonical links in fully translated sites is not recommended. You can find more information about this and using "hreflang" here: hidden link

We have some documentation about SEO settings and WPML that may be helpful for you:

https://wpml.org/2017/09/multilingual-seo-8-hints-and-tasks-for-you/
https://wpml.org/2016/05/hreflang-tags-multilingual-wordpress-sites-explained/

Hope this helps you with the settings,

Best regards,
Ricardo

March 2, 2018 at 7:48 am #1533954

Kaloyan

Hello Ricardo,

Canonical urls are not invented so you can point to the same article, or lead them to another source of your website, they are to point where the original content is from, so if it is from external website you can link to that, yoast permit it and it is set and working without WPML.

I think you overlooked the task, the url now is clearly not the same as the page url:

hidden link

It is because the domain got overwritten, originally it should be:

hidden link

So clearly wpml overwrites the domain name and doesn't allow external links to be there, because it just overwrites the domain name.

This is major problem for SEO and should be fixed.

Regards
Kaloyan

March 2, 2018 at 5:00 pm #1534637

Ricardo Alday

Hi Mariana,

So if I understand correctly, WPML is overwriting the canonical URL you entered into the Canonical URL field for the post/page? If that's the case try this (backup your entire site first):
Open sitepress-multilingual-cms/classes/compatibility/wpseo/class-wpml-wpseo-filters.php and comment out or remove this line (33):

add_filter( 'wpseo_canonical',                    array( $this, 'canonical_filter' ) );

Let me know if that helps,
Ricardo

March 5, 2018 at 8:14 am #1535827

Kaloyan

Hello Ricardo,

Yes your solutions worked, in order to have it in the next update, can I move this file to my child theme?

Regards

March 5, 2018 at 2:06 pm #1536378

Ricardo Alday

That's not going to work. Let me check with our developers for a better implementation method.

August 6, 2019 at 2:51 pm #4348761

timF-10

Hi, any news on how to make this permanent? I have the exact same issue. Commenting out the line works, but how to prevent it gets overwritten in the next release?