3

I have just finished a client’s website and now they want to have different languages.

At the moment the sites content is stored on tables in a MySQL db:

  • pages: seotitle, seodesc, smallHtml, fullHtml

  • products: ID, seotitle, seodesc, smallHtml, fullHtml

I was thinking a good way to do it would be to have an extra table:

  • languages: ID, LanguageCode, language

Then modify the pages and products table to:

  • pages: slug, seotitle, seodesc, smallHtml, fullHtml, languageCode
  • products: ID, slug, seotitle, seodesc, smallHtml, fullHtml, languageCode

So I would be using a query like

SELECT * FROM pages WHERE slug = '$slug' AND language='$language'

Should I set $language as a cookie or session?

Also, I am stuck on what to do as far as SEO goes. At the moment the site URL structure is /pages.php?slug=page-slug. This gets rewritten by mod_rewrite to /pages/page-slug.

So I was thinking of having /pages.php?slug=page-slug&code=languagecode rewriting to /pages/page-slug/languagecode. Same for products.

Would this be a good method or can you see it failing somehow?

If anyone has any better methods or links to resources I may have missed that would be much appreciated.

Thanks for reading.

EDIT/////

If I was to use this method http://en.kioskea.net/faq/596-change-the-language-of-your-website and change the language behind the scenes, without changing the URL structure how would Google handle this?

Tommy Arnold
  • 3,339
  • 8
  • 31
  • 40

2 Answers2

5

Google and other search engines don’t try to guess the language by inspecting the URL, it’s the content that matters:

Google uses the content of the page to determine its language, but the URL itself provides human users with useful clues about the page’s content.

This is why you should declare the content’s language properly: In HTTP use Content-Language to specify the document’s default language and use the lang attribute for language changed within the document.

Having a multilingual web site you should also consider doing some kind language negotiation (see also my answer to Detect Browser Language in PHP); but also take the nuances into account that are associated with it (see Common HTTP Implementation Problems).

But yet, choosing an appropriate URI structure is also important – even if only for the users. That means the URI should reflect the chosen language (unless you want to provide a language-independent entry point for language negotiation).

But what URI design you choose is up to you. Do it from the user’s perspective.

Community
  • 1
  • 1
Gumbo
  • 643,351
  • 109
  • 780
  • 844
3

Basics, each table should have an ID, looks like Pages would be missing it if you changed it as proposed.

Many major websites (including Wikipedia) have the language prefixed as a subdomain using the 2 digit ISO abbreviation for languages, e.g. English = en, etc. Which would make your URLs look similar to en.websitename.com. Bear in mind though that most multi-language websites don't have the default language shown in the URL, so if English is your default then English would be www.websitename.com but the French would be fr.websitename.com. This seems to be a commonly accepted approach, and also helps the URLs look cleaner when viewing subpages. Your other page URL structure looks SEO friendly apart from the language bit.

You'll need to think about how a visitor is first going to enter your domain, whether to your main homepage or to a subpage (via search engines mostly). With that you should then try and redirect the user to the language from there web browser (see here for a good way to do this). Although it's also a good idea if the content the user (on there first visit) was going to is different to the language of there browser then it's good for usability to offer a clear way to access both versions, which you would then remember via a cookie/session.

Other SEO tips: see here for the basics.

Community
  • 1
  • 1
Alex
  • 1,584
  • 1
  • 19
  • 29
  • “For SEO, Google prefers the language to be prefixed as a subdomain using the 2 digit ISO abbreviation for languages, e.g. English = en, etc.” – Please verify this statement. – Gumbo Mar 12 '11 at 20:12
  • The link that aSeptik linked to is answered by Nathan Buggia (of Bing Search) and states pretty much the same. The 2 digit format is the norm for most major websites I've seen (that don't use different TLDs), Wikipedia being the best example. – Alex Mar 12 '11 at 20:34
  • 1
    @Alex: I’m familiar with the language tags. But why is a subdomain with that language tag preferred by Google? I mean, all that I can find is: [“Google uses the content of the page to determine its language, but the URL itself provides human users with useful clues about the page’s content.”](http://www.google.com/support/webmasters/bin/answer.py?answer=182192) – Gumbo Mar 12 '11 at 20:46
  • @Gumbo The only Google specific page talking about URL structure I can find is http://www.google.com/support/webmasters/bin/answer.py?answer=76329 and http://www.google.com/support/webmasters/bin/answer.py?answer=44231 talking about www vs non-www. – Alex Mar 12 '11 at 20:57
  • There is also this quote "If you decide to use dynamic pages (i.e. the URL contains a "?" character), be aware that not every search engine spider crawls dynamic pages as well as static pages. It helps to keep the parameters short and few in number." from http://www.google.com/support/webmasters/bin/answer.py?answer=35769 but can have a few different interpretations. The main reason for me recommending this is from people I've worked with who have produced major German/English websites and the benefits they saw when they switched URL language structures. This is certainly not proof though. – Alex Mar 12 '11 at 21:01
  • @Gumbo I've rewritten the answer – Alex Mar 12 '11 at 21:43
  • read this too: http://stackoverflow.com/questions/1828317/internationalization-and-search-engine-optimization – Luca Filosofi Mar 13 '11 at 00:04