Cannot Delete Master Page: This item cannot be deleted because it is still referenced by other pages

A few weeks ago, I was getting an issue when trying to delete a Master Page from the master page gallery in SharePoint 2013. As I tried to delete the file, I was presented with the error “The item cannot be deleted because it is still referenced by other pages”.

The master page was no longer in use, and it didn’t have a HTML master page associated with it. If you get this error when you have a HTML master page associated with your “.master” file, make sure you disassociate this first, or delete the “.html” file. It did have a preview file with it to allow it to work in a composed look, which I deleted, but still got the same error.

The Solution

In the end, I remembered that the Master Page had been used as part of a Composed Look. Even though the composed look wasn’t being used anywhere, it was holding a lock on the file. To solve this, I went to the Composed Look list (/_catalogs/design/AllItems.aspx) and deleted the list item. Once this was gone, I was free to delete the master page.

To summarise, if you’re having this problem try the following steps:

  1. Change the Master Page of all sites in the Site Collection to something other than the master page you’re trying to delete
  2. Delete any associated HTML files
  3. Delete any associated Preview files
  4. Delete the Composed Look list item

As a side note, while looking into this issue, I saw a number of posts where this was a problem in 2007 /2010 which referenced this support post. I also gave this a try, which didn’t help at all.