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 7 replies, has 2 voices.

Last updated by patrickM-7 3 years, 4 months ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
April 8, 2016 at 7:57 pm #857172

patrickM-7

I am trying to:

Setup my site correctly for indexing by search engines.

URL of (my) website where problem appears:

It's an acceptance environment to which I'd rather not point any links.

I expected to see:

* HEAD: x-default
* Sitemap: <xhtml:link rel="alternate" hreflang="en"...

Instead, I got:

None of the above.

Steps to duplicate the issue:

I read this ultimate guide on hreflang by Joost de Valk (WordPress SEO):
hidden link

It lists three ways to implement language choices so Google can show the visitor the right page in the search engine results pages:

1. HTML hreflang link elements in your <head>
2. hreflang HTTP headers
3. An XML sitemap hreflang implementation

The first and third seem to be supported by WPML but as far as I can see they're not working 100% yet.

For #1 x-default is missing.

On the forum, this was announced and acknowledged on April 11, 2013:
https://wpml.org/forums/topic/x-default-hreflang-when-to-expect-support-for-this-in-wpml/

But as far as I can see, the header is not present yet. I did find a few posts pointing towards custom code adjustments in WPML but these would probably be overwritten on a next update:
https://wpml.org/forums/topic/code-for-x-default/

Also, Stackoverflow tells me the code snippet might be outdated:
http://stackoverflow.com/questions/36434505/how-to-add-hreflang-x-default-in-wpml-3-3-6-plugin

For #3 The WordPress SEO sitemap doesn't output anything multilingual at the moment (WordPress 4.4.2, WordPress SEO 3.1.2, WPML 3.3.7)

We switch language by folder but didn't assign a folder to the default language. I tried enabling the setting and each folder seems to get its own sitemap. Is that how it's supposed to work? If this is the way to go, we seem to have to come up with something for the homepage.

Because of the overhead in the header of each page with code that's targeted towards search engines, I prefer the XML sitemap. But as we're probably supporting <5 languages in the foreseeable future, the HEAD could work for us.

April 11, 2016 at 8:19 am #857810

Dat Hoang

#1, hreflang tags in the header.
Our developers have not implemented this yet.
And I think we move ahead with this hreflang value "x-default" for the root page in the case you select "Use directory for the default language" - hidden link

However, I'd like to be more clear: you want to set at least a language with the hreflang value "x-default", right?

#2, Sitemap
WPML is filtering to make sure WordPress SEO displaying all posts in the sitemap.
We don't support hreflang in any sitemap yet.

Currently under each language folder you can access to sitemaps if you type the links directly in the browser address. But you should submit only the one in your default language, which includes all posts in all languages.

April 19, 2016 at 8:33 pm #864826

patrickM-7

Hi Dat,

Sorry my reply took a few days. I was expecting WPML to take care of technicalities like this. I've paid for this plugin specialized in making WordPress multilingual and didn't expect to have to dive into details at all.

As far as I understand we have three options to tell Google about languages:

1. HTML hreflang link elements in your <head>
2. hreflang HTTP headers
3. An XML sitemap hreflang implementation

Source, this post:
hidden link

So WPML can probably provide either #1 or #3.

#1. X-HREFLANG IN HEAD

I was really surprised to see x-hreflang isn't picked up yet, it was sort of promised in 2.8 over here:
https://wpml.org/forums/topic/x-default-hreflang-when-to-expect-support-for-this-in-wpml/

Reading the href ultimate guide, I understand every post should point to the default language equivalent.

I asked a developer to add x-hreflang to all pages and point me towards the code so I can share it with you. I hope it helps you incorporate the tag into the next version of WPML so all users can benefit.

functions.php:
require_once get_stylesheet_directory() . '/customized-seo-default-lang.php';

$customizedSEO = new CUSTOMIZED_SEO_HeadDefaultLang($sitepress);
$customizedSEO->init_hooks();

In customized-seo-default-lang.php it looks like he copied code for "HeadDefaultLang constructor" from WPML and changed this part of the code:

if ( $is_valid ) {
foreach ( $languages as $code => $lang ) {
//if ($code == $defaultLanguage) {
if($code == apply_filters('wpml_default_language', NULL )) {
$alternate_hreflang = apply_filters( 'wpml_alternate_hreflang', $lang['url'], $code );
printf( '<link rel="alternate" hreflang="x-default" href="%s" />' . PHP_EOL, str_replace( '&', '&', $alternate_hreflang ) );
}
}
}

#3. XML SITEMAP

You mention you only filter posts/pages for WordPress SEO. I read this question in the ultimate guide: "Does the Yoast SEO Plugin (free version) take care of these aspects (e.g. multilingual sitemaps, x-default, etc.)? We are using WPML and would love to have it work just perfect together with your plugin."

Joost seems to expect you guys take care of the XML: "WPML does that actually, we don’t :)"

For end users, that's kind of a dead lock situation 🙁

I'll post a link to this thread over there as well.

Note you say: "But you should submit only the one in your default language, which includes all posts in all languages." We setup WPML to include a subfolder for the default language. Each language sitemap -mainly- contains pages of it's own language. Only the homepage seems to be repeated but I'll file a separate ticket for that once we have that more clear.

April 20, 2016 at 9:30 am #865149

Dat Hoang

Thank you so much for your thought and info.

#1. X-HREFLANG IN HEAD

Reading the href ultimate guide, I understand every post should point to the default language equivalent.

Thank you, this makes sense.

I will pass this code to our developers and the code change as well.

#3. XML SITEMAP
I see your point.
Actually we have not provided hreflang in the sitemaps yet.
This should go to our feature request as well.
It would be better if we have only one way for the same purpose.

I'm reporting both issues to our developers and we will give the feedback to you soon.

April 21, 2016 at 9:31 am #866139

Dat Hoang

Thank you for your patience.

Our developers were notified about these feature requests.
We will consider them and may add them in the future.

However we can not promise exactly when they're available in our code.

May 11, 2016 at 7:19 pm #880559

patrickM-7

Today I received an email message from WPML promoting "Using hreflang tags correctly to target the right audience". And this thread's title now has a prefix "[Fixed in next Release]". So the fix is part of WPML 3.4?

May 12, 2016 at 2:12 am #880688

Dat Hoang

I'm sorry for making it confused with the status "Fixed in next release". It should be "Escalated to WPML developers team", which is pretty new in our support forum.

Actually this is considered as a feature request because our current code does not intend to do something like so.

We will consider it again and may add it in the future.

Like I said above,

However we can not promise exactly when they're available in our code.
May 12, 2016 at 6:08 am #880740

patrickM-7

Ok thanks for the update.

I guess you should also inform marketing "Using hreflang tags correctly to target the right audience" is not possible with plain WPML yet 😉