Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to make a website in two languages. I've looked around and settled on the directory option of separating both languages. How do I make it work?

Let's say I have the following three files for the landing homepage, the English page and the Spanish page:

http://www.domain.com/index.html
http://www.domain.com/en/index.html
http://www.domain.com/es/index.html

Let's also say that /index.html will be in English, with a link to /es/index.html. In turn, /es/index.html will have a link to the English version. Would this be back to /index.html or to /en/index.html? How do I get both English versions (the one at the root and the one in the directory) to actually be the same file in the same directory?

I'm new to this, so I'm not using any scripts yet. To me, the obvious solution is to duplicate both English versions and have the one at the root point to files under the /en/ directory, but I'm not a fan of duplication and I've learned that search engines really frown upon that. Anyone point me in the right direction?

share|improve this question
    
Actually, what you're talking about technically isn't considered duplication to search engines like Google. It's only duplicate content if, say, the navigation and some peripheral text on the site is translated, but the main content is identical (i.e. same language, same text). Just use appropriate link attributes (<link rel="alternate" hreflang="de" .../>) to let the search engines know where the different translations are. –  Lèse majesté Feb 3 '11 at 0:27

3 Answers 3

up vote 3 down vote accepted

I think you are on the right track here. There are a few ways I've seen this done:

  1. Have the www.domain.com/index.html page be a simple language selection page with only links to the en and es home pages. Personally I find this annoying, but I still see it all the time.

  2. Just sent everyone to the english version and have a link from there to the spanish version. This is probably the best option if a large percentage of your users will be english speaking.

  3. Attempt to auto-detect language in some server side code, probably by looking at the Accept-Language header to see which language the user prefers, then send them to the appropriate page.

share|improve this answer
    
I also find #1 annoying and will end up using #2 for this project and let the user select their language of choice. Thanks! –  Ricardo Feb 3 '11 at 3:41

Even though you're new to this, I suggest I'd do is to use a PHP script to handle this.

You can use mod_rewrite to rewrite the urls /en/, /es/, etc. to say language.php?lang=en, set a cookie for the language, and redirect back to index.php or even mod_rewrite back to /en/index.php.

Otherwise, @Eric Petroelje's answer is your best bet.

share|improve this answer
    
Thanks for the mod_rewrite tip. I'll keep it in mind for when I set up a server, which will probably happen sooner than I expect. For now I'm sticking to html-css with no server-side dealings. –  Ricardo Feb 3 '11 at 3:46
    
np. Glad to offer suggestions. –  Zack Feb 3 '11 at 18:54

To avoid having to duplicate the index.html on www.domain.com/index.html and www.domain.com/en/index.html , the best SEO friendly solution is to use a 301 redirect on your .htaccess file (works only on Apache servers).

Edit or create your .htaccess file adding the following line :

redirect 301 /en/index.html http://www.domain.com

This way, whenever someone tries to access to www.domain.com/en/index.html will be automatically redirected to the domain index, and you don't have to worry about different versions of the same file or analytics and ranking being divided between the duplicated index.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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