WPML allows you to create a specific root page for your site. This means that regardless of the available languages in your site, the starting page will be the same for all your visitors
WPML lets you create virtual directories for all languages, including the default language. These are not real physical directories on the server’s drive, but virtual directories that only appear in URLs.
With language folders for all languages, your site’s structure can look like:
To enable this, go to WPML → Languages and scroll down to the Language URL format section.
The root page of your website is the content that loads when visitors access your domain name, i.e. “mysite.com” in a web browser. In case you are using the Use directory for default language option, the starting page will be the same for all your visitors, regardless of the available languages on your site.
The following image displays a simple example of a root page, which features a welcome message and links to the site’s language versions.
In order to use a root page, you first must select the Different languages in directories option.
Then, enable the Use directory for default language option.
Now, you must choose what goes into your site’s root URL. For the root URL, you can choose between a WordPress page or an HTML file.
When you choose an HTML file, you need to provide its path. If the path starts with a slash “/”, it is an absolute path on the server. Otherwise, it is relative to the WordPress directory.
You can upload the HTML file you want to use for your root page using a FTP program and place it under your site’s WordPress directory as shown in the following image.
Once the file is uploaded, you can set its relative path, by simply specifying the file’s name. For example, “root-page.html”, as shown in the following image.
If you want to use an absolute path on your server you can upload your HTML file in any of the site’s folders, as displayed in the following image.
Once the file is uploaded, you can set its absolute path, for example “/home/andres/root-page.html”.
If you choose A page option, save your settings first and then click on the Create root page link.
This redirects you to the WordPress page editor interface.
Here, you can design how you want your site’s root, main landing page to look like. For example, some sites display a welcome message and provide a large language selection interface.
Once you have added your content, save the page.
That’s it! When visitors come to your site, this page will be used as the root, landing page, regardless of the available language preferences.
Sometimes, you might want to redirect your root domain to the directory of the default language. In other words, if English is the default language and someone visits www.yoursite.com, they are redirected to www.yoursite.com/en/.
To achieve this, start by creating a PHP template for your site’s theme. Usually, you should add such PHP files to a child theme.
Add the following content to your new PHP page template file:
<?php /* Template Name: Root redirect */ wp_redirect( home_url() ); exit; ?>
Now, go back and edit your root page.
In the right sidebar, expand the Page Attributes section and select the template you just created.
When done, make sure to update the page.
Now, your root page will redirect to the default language directory.
When you select to use a standard WordPress page as your root page, it will not be listed on the usual Pages listing page.
To edit your root page, you need to go to the WPML → Languages page, scroll to the Language URL format section, and click the Edit root page link.