Skip Navigation
Updated
March 11, 2021

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.

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:

mysite.com/en/
mysite.com/es/
mysite.com/fr/

To enable this, go to WPML → Languages and scroll down to the Language URL format section.

Directory for the default language
Directory for the default language

What is a root page and do I need one?

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.

Front-end root page
Front-end root page

Setting up the root page

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.

Selecting 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.

Using a relative path

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.

Uploading an HTML file to your WordPress directory
Uploading an HTML file to your WordPress directory

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.

Add the HTML to the HTML file option
Add the HTML to the HTML file option

Using an absolute path

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.

Upload a HTML file in your directory
Upload a HTML file in your directory

Once the file is uploaded, you can set its absolute path, for example “/home/andres/root-page.html”.

Selecting a WordPress page

If you choose A page option, save your settings first and then click on the Create root page link.

Click on the Create root page link
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.

WordPress root page example when using Block editor
WordPress root page example when using Block editor

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.

Redirect the Root Domain to the Default Language Directory

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:

Root Redirect
<?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.

WordPress root page example when using Block editor, Page Attributes drop down
WordPress root page example when using Block editor, Page Attributes drop down

When done, make sure to update the page.

Now, your root page will redirect to the default language directory.

How to edit an existing root page

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 WPMLLanguages page, scroll to the Language URL format section, and click the Edit root page link.

Link to edit an existing root page
Link to edit an existing root page