Completely deleting web parts on a SharePoint page

Sometimes you need to remove web parts from your SharePoint page. Seems like a typical, everyday thing for a Site Owner to have to do. And it is. But it depends on the situation, how you remove the web part, and why you’re doing it. The thing is, removing a web part in SharePoint isn’t always as simple as it seems. And in these unique situations, you want to make sure you’re doing it right so you can avoid some unexpected annoyances along the way.

The major takeaway from this post is in SharePoint 2013 and earlier versions, when you delete a web part, sometimes doesn’t actually get fully removed. And in SharePoint 2016 and SharePoint Online, the same thing still occurs if you close a web part. So even if you think you got rid of these web parts, they’re still stored in a back room in SharePoint. It’s kind of tricky. And I’ll cover how to deal with the situation below.

Why deleting web parts makes sense

The most likely times you need to remove web parts from your SharePoint page and these are your options for doing so:

  • Minimize: Useful if you want to “close up” a web part temporarily. Its title is still visible on the page, so it’s obvious it’s still there, it’s just not taking up much screen space, which can be useful in certain situations. It’s kind of like the plus sign that pops up when you group items in a list that lets you expand/close lower items.
  • Close: Similar to delete, but the web part still exists on the page, even though you (and your users) aren’t really aware of it.
  • Delete: The web part is completely removed from the page, at least in SharePoint 2016 and SharePoint Online. (Note: in my experience, this sometimes functioned identically to a “close” in SharePoint 2007 and SharePoint 2013. I’m sure it’s not a random occurrence, but I never figured out the pattern of why it did which when it did.)

One thing that happens occasionally is a web part—usually a Content Editor Web Part or Script Editor Web Part that include some HTML or Javascript code—causes an unexpected problem that produces an error on the page. Unfortunately, sometimes the error can actually remove the ability to edit the page. And you’re up a certain creek.

 

But, generally, clicking Delete on a web part will do what you need it to do.

Deleting the default promoted links in a new SharePoint site: I mean, let's face it. This is always the first thing we delete in a new site, right?

Deleting the default promoted links in a new SharePoint site: I mean, let’s face it. This is always the first thing we delete in a new site, right?

 

 

Problems you can face removing web parts

As mentioned above, if your web part includes code, it could cause an unexpected error that makes the page unresponsive, affecting the ability to continue editing the page, adding or removing web parts, or doing basically anything else. It’s kind of a living hell for a dedicated SharePoint Site Owner.

 

The other major issue is SharePoint’s well-documented threshold of 25 web parts max on any SharePoint page. “Threshold” is a technical term of Microsoft’s and it basically means “recommended number you shouldn’t exceed”. Any time you go over that, the load time on the page could get slow. Why might this affect you? If you typically close web parts rather than delete them, the web parts don’t actually leave; as you add new web parts, you’re stacking the total parts on a page, potentially bringing you close—or exceeding—the maximum number of web parts.

 

This could also impact you when you delete web parts in SharePoint 2007, 2010, and 2013. As mentioned above, I couldn’t ever figure out how SharePoint made the decision, but it seemed some deleted web parts were stored as if they were closed, while others were deleted as intended.

 

How to fully remove the web parts

The only way to fully remove the web parts that you close (SharePoint 2016 and SharePoint Online) or sometimes close (SharePoint 2007, 2010, 2013) is to go through an annoying little back door to a SharePoint page that you likely don’t know about. It’s basically a Recycle Bin for web parts on a given page, and each page has this secret Recycle Bin. It’s called the Web Part Page Maintenance page.

 

And how to do it? Add ?Contents=1 to the end of the page address.

 

Example:

  • https://contoso.sharepoint.com/teamsite/SitePages/Home.aspx becomes
  • https://contoso.sharepoint.com/teamsite/SitePages/Home.aspx?Contents=1

Yes, this will work in any on-prem SharePoint environment, not just SharePoint Online (the example I used above). Also, as a reminder, the ?Contents=1 must follow the page name ending in .aspx. Otherwise you’re not calling out the contents of that page.

 

And this is the page that comes up:

SharePoint Web Part Page Maintenance Page

SharePoint Web Part Page Maintenance Page

 

In this example, my home page has three web parts. First is the Newsfeed (Site Feed, seen above). The second and third are the default Documents library, displayed twice. I added the library once, then closed it. Because it appears it was missing, I added it again in the same web part zone (a mistake that easy to make by both a n00b and veteran Site Owner). So I actually have three web parts on this page, even though only two display. See the actual page (with my commentary) below.

Home Page with Deleted Web Parts

Home Page with Deleted Web Parts

 

From the Web Part Page Maintenance page you can delete web parts by checking the appropriate box and clicking Delete. The closed or deleted web parts (depending on SharePoint version, as mentioned above) are the ones that display as “No” under “Open on Page?”. Be careful though: you’re removing web parts from the background and this operation is likely without an undo button. You can also close web parts from this page. I’m not sure what Reset does.

Now, it would be nice to say that it happens this way all the time, but it’s not the case as far as I’ve seen. Sometimes after you close a web part and re-add it, the title of the new web part gets a [2] after it, which makes sense (like “Documents [2]”, as would happen if you added the same web part twice on the same page). But sometimes (as shown above) it doesn’t do that. I have found no pattern there. Also, sometimes you get the close option in the edit web part drop-down list, but sometimes you don’t. I again have found no pattern there.

 

Conclusion

Although rare, you may sometimes have an issue requiring you to go in to the Web Part Page Maintenance page to, well, empty your web part Recycle Bin for lack of a better term. And this is especially useful if you’ve screwed up some code in a Content Editor Web Part or Script Editor Web Part. And it’s also useful when you’ve bitten yourself because you’ve overused the close or delete option for your web parts and end up exceeding Microsoft’s suggested maximum of 25 web parts per page in SharePoint.

 

And, here’s to another subtle thing that SharePoint does that you don’t even know about, that is until your untimely discovery when it really matters. Unless, of course, you read this ahead of time and keep it in mind going forward.

References
icansharepoint. (2016). Completely deleting web parts on a SharePoint page – icansharepoint. [online] Available at: http://icansharepoint.com/completely-deleting-web-parts-on-a-sharepoint-page/ [Accessed 28 Feb. 2017].

Reproduced under permission from Matt Wade

Share this on...

Rate this Post:

Share: