Create a new page language branch programmatically in EPiServer

This article was migrated from an older iteration of our website, and it could deviate in design and functionality.


This article describes how to create a new language branch programmatically for an existing page in EPiServer.

Estimated read time : 1 minutes

Jump to

Create language branch in code using the CreateLanguageBranch method

The following code sample illustrates how to create a new language branch for an existing page in EPiServer:

// Reference to the page we want to create a new language branch for
var pageLink = new PageReference(123);
 
// Create swedish language version
var newLanguageBranch = DataFactory.Instance.CreateLanguageBranch(
                        pageLink, 
                        new LanguageSelector("sv"));
 
// Set page name
newLanguageBranch.PageName = "Page in another language";
 
// Save the page regardless of current user permissions
DataFactory.Instance.Save(
   newLanguageBranch,
   SaveAction.Save,
   AccessLevel.NoAccess);