You can automatically set the language of a visitor based on the path in the URL.
- Localize for visitors in France: https://localizejs.com/fr
- Localize for visitors in Germany: https://localizejs.com/de
Using language subdirectories to structure your multilingual site is a recommended best practice for optimizing SEO. We recommend setting up language subdirectories for your website to optimize your website for search engines and to ensure that the translated versions of your website are appropriately indexed.
Only 1 Copy of your Website Required!
Keep in mind that when using the subdirectories method 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.
Our subdirectories language detection works "out-of-the-box". What that means is if you have correctly configured your server to use subdirectories like "localizejs.com/fr", and the language "fr" is active in your project, the page will get translated to "fr" when a user visits the page, without having to switch the language themselves!
To allow search engines to index the target language versions of your site separately from your source language version, you should add HREFLANG tags to all of your pages. Read more here...
You should also have the appropriate Canonical tag for each page. Read more here...
(see also Language Subdomains)
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.:
- English (source language): https://localizejs.com/
- Spanish: https://localizejs.com/es/
- French: https://localizejs.com/fr/
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)
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.
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.
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.
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.
Updated 5 months ago