15 Posts
michaelq
7 years ago
Topic

Hello

I am developing a multilingual site for case studies, and I have some questions regarding "SEBLOD Canonical URL" field in this environment.

The front end of my site is available in English, French and in German. The case studies itself are available for all language, nevertheless if they are written in English, French and in German. Therefore same case study can be found and read, regardless of whether the language of the front end is set for English, French or German. This means the same content can be found more than once. With regard to SEO this is obviously unfavorable. That's why I wanted to use the SEBLOD Canonical Field. Is set the field to the German menu item, which is default language.

I made the following settings in the canonical field:

("Content" is set to "- Current -")

But now, the one and the same content has a different canonical tag in the header of the page source, when the front-end language is changed. The menu item is correct in the URL, but always the language code of the selected front end language is in the canonical URL too.


Not to give the language code in the URL is the option I thought about first, so I've tried this setting (Joomla System Language Filter plugin). The language code will not be given only in the site default language, as soon as the site language is change in the front end, the code it's back.

„Use URL Rewriting“ and „Search Engine Friendly URLs“ is set to „YES“. No change when both is set to „No“ the language code is still in the URL as a parameter.

I am now not sure if I'm doing something wrong in the settings of Canonical field. Or does the Canonical Field not work in multilingual environments?

Best regards, 

Michael

Get a VIP membership
4229 Posts
Kadministrator
7 years ago
0
Level 1

Canonical url works per language as normally contents are different for each language. You can create feature request on github to add "one content for all languages".

15 Posts
michaelq
7 years ago
0
Level 1

I created now a custom "Canonical Field" for my content.

I added a field 42 in the "Content View" position "Main Body" with the following code in "Prepare Content".

$uri = JURI::root();
$lang =& JComponentHelper::getParams('com_languages')->get('site');
$caseid = JFactory::getApplication()->input->getInt('id');

$db = JFactory::getDBO();
$query = $db->getQuery(true);

$query->select($db->quoteName(array('a.id','a.alias','b.id','b.alias'), array('idcase','aliascase','idcat','aliascat')));
$query->from($db->quoteName('#__content','a'));
$query->join('LEFT', $db->quoteName('#__categories','b').' ON ('.$db->quoteName('a.catid').' = '.$db->quoteName('b.id').')');
$query->where($db->quoteName('a.id')." = ".$db->quote($caseid));

$db->setQuery($query);

$resultasc=$db->loadAssoc();

$doc =& JFactory::getDocument();
$doc->addCustomTag('<link href="'.$uri.substr($lang,0,2).'/'.$resultasc['idcat'].'-'.$resultasc['aliascat'].'/'.$resultasc['idcase'].'-'.$resultasc['aliascase'].'" '.'rel="canonical" />');

The code gets all the information of the case study which is opened in the browser and the system (base URI and default site language). With a query the ids and aliases of the article and category is retrieved. At the end, the custom canoniocal URL is put together and submitted to the header of the document.

4229 Posts
Kadministrator
7 years ago
2
Level 1

Hi,

good solution, would be nice if you create a manual from it so it won't get hidden away in the forums.

15 Posts
michaelq
7 years ago
1
Level 2

Hello 

I created a tutorial with a bit a better code: Canonical URL for "all langauge" content on a multi language site

Best regards

Michael

4229 Posts
Kadministrator
7 years ago
0
Level 3

great, thnx!

Get a Book for SEBLOD