The correct way to add pages by code

In order for back office to have the same content from the changes you made in code, a good idea is to make the changes to a DraftPage of the new page you created and then publish that one.

var draftPage = _draftPageService.Get(page.SystemId).MakeWritableClone();
// make changes
_draftPageService.Update(draftPage);
_draftPageService.Publish(draftPage);
3 Likes