2

I need to rename a bunch of Page layouts and Master Pages without having to re-set the Page Layout to each content page that is using those layouts.

For example:

I have two page layouts - 'Home.aspx' and 'Home1.aspx' - and I want to rename them to something along the lines of 'project1_Home.aspx' and 'project2_Home.aspx'

I can do this fine in Sharepoint Designer but when I try to access a content page using one of the 'Home.aspx' or 'Home1.aspx' layouts I get a "The resource cannot be found." error page. The renaming hasn't taken affect.

I then have to manually go into the Page Settings an re-set the pages in question to access the project1_Home.aspx or project2_Home.aspx layouts.

Can I achieve this programmatically?

I have dozens of page layouts I want to rename (and perhaps move to subfolders) and hundreds of content pages use those layouts so it would take forever manually ! :)

Thanks, del

2 Answers 2

1

You can also run a simple powershell command that will allow you to change multiple page layouts all at once. This is extremely helpful when doing a product version update.

Here is a sample of the powershell script: SP-Update-PageLayouts [-SiteCollectionURL] [-PageLayoutCurrent] [-PageLayoutNew] [-PageName (Page Name | All)] [-ApprovalState ( Publish | Approve )]

0

Yes you can change the page layout that a page uses programmatically.

Refer to the PublishingPage.Layout Property on MSDN which includes a code sample.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.