I deployed a custom master page to top level site collection and now I want to delete that master page but I unable to delete that master page and page layouts from the site collection. I tried Sharepoint designer as well as sharepoint ui but it won’t worked for me instead it throws an error like This item cannot be deleted because it is still referenced by other pages. Please suggest me how I would delete that master page and page layouts????
Navigate to /_layouts/15/sitemanager.aspx. Select master page in right panel. From the toolbar select Show Related Resources.
Review related resources & take appropriate action to disconnect master page.
First set another master page (inbuild) as default one by SharePoint Designer. Then you can delete custom master page.