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?
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.
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);
If you would like to update the url segment, you must also update this property:
newPage.URLSegment = "new-url-segment";