Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

How do you programmatically rename a page?


I am using the IContentRepository to copy an existing page programatically, and then creating a writable clone to modify the newly copied page's fields.

One thing I am looking at doing is renaming the page.  When I update the "Name" property, I see that this is now reflected within the Epi Edit interface on the property panel.  However, the page is not renamed within the Page Hierarchy.

What is the proper way to rename a page programatically?

Aug 14, 2020 19:27

Hi Dylan

The proper way is to create a clone, change the Name property and publish the changes.

Did you remember to publish while saving the changes? If not, you will only see the Name changed in the editor view, not in the tree view.

Aug 15, 2020 8:37

Hi Dylan,

After creating a clone change the name of the page and publish it programmatically:

var repo = ServiceLocator.Current.GetInstance<IContentRepository>();
repo.Save(newPage, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);
Edited, Aug 16, 2020 2:27

If you would like to update the url segment, you must also update this property:

newPage.URLSegment = "new-url-segment";
Edited, Aug 17, 2020 8:16
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.