SEO Ex: Localize w/Subdirectories

We practice watch we preach! Check out this example of using subdirectories to optimize SEO.

Using subdirectories to optimize your page rankings for a website that is translated into multiple languages is one of the recommended best practices for SEO.

Here at Localize, we use the subdirectories approach for our own website.
Each language has a unique subdirectory, using the language code, e.g.:

Below is an example of searching in Google for a specific phrase that's found on the landing page of our website: "The Industry's Leading Localization Platform".

The source language is English, and we show below the same phrase translated into Spanish and French. We use Google to search for the phrase in the 3 languages. (we search using Google in this example but the results are the same with other search engines)

Only 1 Website Required

Keep in mind that for this example, there is only 1 website, with the translations being managed using the Localize dashboard. Based on the chosen language, the appropriate translations are automatically displayed in the user's browser, but they are all being served from the same website.
This eliminates the need for you to maintain multiple websites, but from Google's perspective they essentially ARE different websites, thus providing you with search results in the respective languages. This allows your users to search for and find your website in their native language.

English (source language)

Here we search Google for the phrase in the English source language:
"The Industry's Leading Localization Platform"

Google finds the phrase in English and displays a reference to the page.

Here is the page that Google found in English. Note the URL in the address bar: https://localizejs.com.
There is no subdirectory in the URL since this is the source language.


Spanish (target language)

Here we search Google for the phrase in the Spanish target language:
"La plataforma de localización líder en el sector"

Google.es finds the phrase in Spanish and displays a reference to the page.

Here is the page that Google found in Spanish. Note the URL in the address bar: https://localizejs.com/es/.
The subdirectory in the URL includes '/es/' at the end, the language code for Spanish.


French (target language)

Here we search Google for the phrase in the French target language:
"La plateforme de localisation leader de l'industrie"

Google.fr finds the phrase in French and displays a reference to the page.

Here is the page that Google found in French. Note the URL in the address bar: https://localizejs.com/fr/.
The subdirectory in the URL includes '/fr/' at the end, the language code for French.


Language Switching Technical Details

The main thing required from your development team would be to set up your web server to point the target language subdirectories to your main website. This could be done using Javascript on the frontend, or some other method on the backend at the server level.

So for example, you would want the URL https://localizejs.com/es/ to point to https://localizejs.com/ behind-the-scenes, BUT you would want your user to still see https://localizejs.com/es/ in the address bar of the browser.

After the above has been setup, you would include the following modifications to the default Localize code snippet. This code checks the URL for a language code directly after the forward slash after the domain name. If it finds one it changes the target language to that language (else it displays the English version of the site).

  <script>
    var urlLang = window.location.pathname.split('/')[1];
    var targetLang= (urlLang && urlLang.length === 2) ? urlLang : 'en';

    Localize.initialize({
      key: '3cMhq5cVLOzKE',
      targetLanguage: targetLang,
      rememberLanguage: true
    });
  </script>

Updated about a month ago

SEO Ex: Localize w/Subdirectories


We practice watch we preach! Check out this example of using subdirectories to optimize SEO.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.