We have just upgraded to 1.7.6.5. We have a 1 store, 1 language setup.
We correctly have our alternate link tag rendered in the HEAD for each page, however for every page that isn't a product or the homepage, the value is the ugly (not pretty) permalink URL.
We do not want this URL to be seen by Google (or anyone) - we want the pretty permalink URL instead as I am sure everyone does.
Examples:
A CMS page https://www.dynveo.fr/content/a-propos-de-nous.html
Has alternate value https://www.dynveo.fr/index.php?controller=cms&cms_rewrite=
Or Blog posts (from PrestaBlog module) https://www.dynveo.fr/blog/bien-choisir-son-huile-de-krill-n3
Has alternate value https://www.dynveo.fr/module-blog?id=3&n=3&urlnews=bien-choisir-son-huile-de-krill
Here is an example of the HTML:
<link rel="alternate" href="https://www.dynveo.fr/index.php?controller=cms&cms_rewrite=" hreflang="fr-fr">
Alternate links used to modules should be user-friendly pretty URLs ( and not expose the original controller)
Steps to reproduce the behavior:
Thanks for opening this issue! We will help you to keep its state consistent
@PrestaShop/prestashop-product-team Could you check this SEO issue ?
I have the same issue in my module, i needed to delete alternative_langs property by having additional code in my ModuleFrontController, the issue is that my module has some dynamic rewrites and parameters, it's not possible for PrestaShop to get a valid alternative URL language
i was thinking about adding a little fallback to Link::getLanguageLink, like this one:
} elseif (isset($params['fc']) && $params['fc'] == 'module') {
$module = Validate::isModuleName(Tools::getValue('module')) ? Tools::getValue('module') : '';
if (!empty($module)) {
unset($params['fc'], $params['module']);
$moduleInstance = Module::getInstanceByName($module);
if (Validate::isLoadedObject($moduleInstance) && method_exists($moduleInstance, 'getAlternativeLangUrl')) {
return $moduleInstance->getAlternativeLangUrl($module, $controller, $params, (int) $idLang);
}
return $this->getModuleLink($module, $controller, $params, null, (int) $idLang);
}
}
thanks to this, we could create a method getAlternativeLangUrl in our module and handle this on our own
let me know what y'all think, if that's ok, i'll make a proper PR
If you have only one language why you would have an alternative link? But this might be another issue from your module.
If these modules receive a wrong URL from the core, we should improve this behavior.
@kpodemski if you think you have found the solution, don't hesitate to do a PR, the maintainers will be happy to discuss it with you on it.
@MatShir re: "If you have only one language why you would have an alternative link? But this might be another issue from your module."
Your logic is sound, but it is actually recommended best practice from Google - I'll find the link.
And PrestaShop IS doing it, so how about we do it correctly ?!
Hi @jonpontet,
Looking on google support resources, they seem to say it is only required when you have multiple versions of a page for different languages. But I would be happy to see if you have any resource that proves that it could increase the SEO, let me know :)
@MatShir for example on that same page it states:
"Each language version must list itself as well as all other language versions."
Anyway, this is not really the point. The point is that it is currently being outputted in code for just 1 language. So either 1) do not do it at all or 2) do it properly. Don't you think?