In the editor when a content editor uses that page type, assuming you have enabled some languages. On each property that has been decorated with the CultureSpecific attribute, they will be able to set the page to that language and add content against it.

This approach works for a lot of companies, but not all. I've worked on several projects where the website' content (pages images, content) needs to be more flexible. Content editors want the ability to be able to create a completely different menu and page structure for each language. All without affecting everything else.

In these situations, you will need to create a section within the CMS per language. An editor will be able to update each section independently and have complete control to create content however they want to. The solution I outline below is not the only way in code to do this, however, from experimentation I think it is the most flexible way. It will involve three main files:

StartPage page-type: This page type will be used as a placeholder. It will not be used for content editing. All the template will do is redirect a site visitor to the appropriate country landing page. The re-direct logic will be cookie-based. If they have an existing language preference cookie set they will be re-directed to the correct homepage, otherwise, the re-direct will be based on their IP or a default value.

HomePage page-type: This template will be the homepage for each individual language. This is the template content editors will use to add content for each language homepage.

ActionFilterAttribute: The action filter will be used to set the language cookie when a request is made to the server. This code will run before a page controller is executed.

Now you know the approach and the files required. Let us look at the code ⏩

LanguageCookieActionFilter

This code will be executed when a request is made. It will check if a language cookie is set, otherwise, it will create one. This code uses a helper called CookieHelper which looks like this:

Start Page Controller

After setting the cookie, we need a start page controller. This will only be used once in your page tree. The start page will be the root node that all requests come to. It needs to be /:

Its job is to redirect a request to another section in the content tree. This section will be the homepage for the language you are re-directing to!

Homepage Controller

This will be used to create the homepage for each language. The name of this page should map to the name of the language it represents. Each homepages URL segment name should be something like en, es, or it:

Having a separate section in the CMS will allow editors to build the pages how they want to. Happy Coding 🤘