Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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 )]

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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