WPML allows you to create a specific root page for your site. This means that regardless of the languages available on your site, all your visitors will see the same starting page.
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.
Please note that when the Use directory for default language option is set on the WPML → Languages page, a root page must be used.
With language folders for all languages, your site’s structure can look like:
To enable this format, go to WPML → Languages and scroll down to the Language URL format section.
On This Page:
- What is a Root Page and Do I Need One?
- Setting Up the Root Page
- Selecting a WordPress Page
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. If 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.
Below you can see 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 must first select the Different languages in directories option.
Then, enable the Use directory for default language option.
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 image below.
Once the file is uploaded, you can set its relative path, by simply specifying the file’s name. As an example, we set the file name to root-page.html.
If you want to use an absolute path on your server you can upload your HTML file in any of the site’s folders.
Once you upload the file, you can set its absolute path, for example /home/andres/root-page.html.
If on the WPML → Languages you choose to show A page for the root URL, 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, you can choose to display a welcome message and provide a language selection interface.
Once you finish adding 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.
When you select to use a standard WordPress page as your root page, you will not find it listed in Pages.
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.
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/.
Start by creating a PHP template for your site’s theme. In most cases, 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 Summary section and select the template you just created.
When you’re done, make sure to update the page.
Now, your root page will redirect to the default language directory.