1

I'm working on a website for Canada which will have French and English versions. For SEO purposes, I would like to avoid using any language tag in URLs because I believe it will have more impact (e.g. example.ca/products better than en.example.ca/products or example.ca/en/products).

I believe this is technically possible because the2 languages are sufficiently different that the URLs won't be conflicting with one another (e.g. if you want a "product" page, it will be /products in English, and /produits in French so you know which language the URL is about).

Since Google (and most likely others) doesn't rely on the URL (nor HTML tags) to determine the content language I don't see any problems with search engines.

To make this possible I've thought about using a cookie distinct from the session cookie (e.g. example.org_language) with long term expiry (e.g. N years) that will memorize the language chosen by the user. That way when people visit the website with a new browser session, they get served the proper language.

I have already given up on users being able to switch one page from English to French: when people will chose English or French from the menu they will be redirected to the corresponding version of the home page.

Do you foresee any problems with not using a language component in the URL (whether domain or path)? (as long as one makes sure URLS don't conflict).

2
  • In your question alone: version, impact, determine (excl. accents), possible, different (excl. accents), (cookie), session, long, page and menu are all valid French words. The assumption that the languages won't overlap is risky. I'd quite easily see a potential usage for page and possibly menu in a URL.
    – Bruno
    Jun 26, 2012 at 12:51
  • True, although for my website (obviously you couldn't have figured out as I didn't mention it) I am expecting URLs to be like phrases, so the combination of words will be unique per language. After posting my question I just realized that for new visitors coming to the home page from search engines, I will have no way of differentiating the 2 languages as the URL will be the same for both (i.e. /) and the user won't be sending the language cookie :( Back to the drawing board...
    – Max
    Jun 26, 2012 at 13:31

2 Answers 2

2

i think the proper way would be:

  • when user accesses site, get his language from browser using javascirpt
  • present the user with what you've found, askig to confirm. than save to session.
  • when the language is set in the session, give back the content in the language, no matter what url the client is visiting

  • google / bots etc. sould not interprete the javascript, they get what they requested via /products /produits ...

btw: if you f* around with products, you should take a look at "nopcommerce" it can take care of this several ways... altough it has its issues ...

0

You can create a $_SESSION or $_COOKIE var to store the language settings. If you're doing a 2 lang site then you can create a language switcher that sets whichever var type you've used to store the set lang, and then reload the index page in that language, but in every case you'll have to choose a default language.

In consideration of returning users cookie would be better than session, but is susceptible to being disabled, so I would recommend using both with cookie being higher priority.

index.php
switch ($_REQUIRE['langvar']):
  case default:
  //load english content
  break;
  case 'french':
  //load french content
  break;

langswitch.php
if ($_REQUIRE['langvar']=='en') {
  $_SESSION['langvar'] = 'fr';
} else {
  $_SESSION['langvar'] = 'en';
}
header('Location: index.php');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.