0

Background

  • We have enabled content translation where we detect based on the content language. This allows us to translate properly as needed, but it has a bad side effect.
  • It will not only add ?language_content_entity=en to the canonical metatag, but if we have any links that return node URLs, it will also append ?language_content_entity=en. This happens for both logged in and anonymous users.
  • Under the metatag settings for each content type we are using the [node:url:absolute] token for any path field and that also returns ?language_content_entity=en in the URL.
  • On the /admin/config/regional/language/detection, under Content Language Detection we have the following Detection Methods enabled in order.

    1. Content Language
    2. Cookies
    3. Selected Language

content language detection

Question

How can we remove ?language_content_entity=en string from the node's path alias and [node:url:absolute] token?

What we tried:

  1. In order to remove the ?language_content_entity=en from the canonical url, we used the best answer from How to override canonical URL?.
  2. tried using hook_link_alter, but it did not find method to remove string from URL.

Only set methods I can see when I do the following:

function mymodule_link_alter(&$variables) {
  ksm($variables['url']);
}

hook link alter

Example:

unami spanish selection

  • "We have enabled content translation where we detect based on the URL. This allows us to translate properly as needed, but it has a bad side effect." Are you sure you don't have other detection methods enabled? – 4k4 Dec 4 '18 at 20:15
  • @4k4 Added screenshot of the settings under Content Language Detection. We essentially have 3 enabled. The issue regarding the ?language_content_entity=en does not exist when Content Language is set to true – usernameabc Dec 4 '18 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.