How to Delete a Page in SharePoint Online?

Requirement: Delete a page in SharePoint Online.

How to delete a SharePoint Online Page?

A SharePoint page is a web page that can be customized to fit the specific needs of a team or organization. These pages can contain a variety of content, such as text, images, and web parts. However, there may come a time when you need to delete a SharePoint page. There are several reasons why you might need to delete a SharePoint page. For example, the page may no longer be needed, or it may contain outdated information. Alternatively, the page may have been created in error or has been replaced by a more updated version. Whatever the reason, it is important to know how to delete a SharePoint page in order to keep your SharePoint site organized and efficient. In this article, I will guide you through the process of deleting a SharePoint page step by step.

There are two main ways to delete a SharePoint page: using the SharePoint interface or using PowerShell scripts. The SharePoint interface is the preferred method for most users, as it is easier to use and requires no technical expertise. However, if you need to delete multiple pages at once, or if you want to automate the deletion process, PowerShell scripts can be a useful tool.

To delete a page in SharePoint Online, follow these steps:

  1. Navigate to the SharePoint site where the page you want to delete is located.
  2. Click on the site settings gear icon in the top-right corner of the page >> Select “Site contents” from the drop-down menu.
  3. In the Site Contents page, locate the “Site Pages” library and click on it. This is where all the pages for the site are stored.
  4. In the “Site Pages” library, locate and select the page you want to delete. You can select multiple pages to bulk delete them.
  5. Hover over the page title to reveal the checkbox beside it. Click on the checkbox to select the page.
  6. A command bar will appear at the top of the page. Click on the “Delete” button on the command bar to delete the page.
    delete a page in sharepoint online
  7. A confirmation box will appear. Click on “Delete” to confirm the deletion.
    Delete a modern pages using PowerShell

The page will now be deleted from the SharePoint Online site. Please note that this action will move the page to the site’s Recycle Bin, where it can be restored within 93 days if needed. After 93 days, the page will be permanently deleted. To recover a deleted SharePoint page, navigate to the SharePoint recycle bin, select the page, and choose “Restore”.

Site owners or members (or site collection administrators) can delete pages and users with the “Contribute” or above permission level. SharePoint will not allow you to do so if you don’t have the necessary permissions to delete a page. You may see an error message that says something like, “You do not have permission to perform this action.”

Delete a modern page using PowerShell

PowerShell can be used to automate various tasks in SharePoint. One of the tasks it can perform is deleting a SharePoint page. Make sure PnP.PowerShell module is installed on your computer before proceeding.

Here are the steps involved in deleting a page in SharePoint Online with a PowerShell script:

  1. Connect to your SharePoint Online site using Connect-PnPOnline cmdlet.
  2. Get the page to be deleted using Get-PnPPage.
  3. Remove the page from the SharePoint Online site with Remove-PnPClientSidePage cmdlet.

To delete a page in SharePoint Online using PowerShell, you can use the CSOM or PnP PowerShell. Here’s how you can delete a page using PnP PowerShell:

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/retail"
$PageName = "About-us.aspx"

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

Try {
    #Get the Page to Delete
    $Page = Get-PnPPage -Identity $PageName -ErrorAction Stop

    #Delete the Page
    Remove-PnPClientSidePage -Identity $Page -Recycle -Force -ErrorAction Stop
    Write-Host "$Page has been deleted Successfully!" -ForegroundColor Green
}
Catch {
    Write-Host $_.Exception.Message -ForegroundColor Red
}

That’s it! The specified page will now be deleted from your SharePoint Online site. Remember to update the page references in your SharePoint Online site to avoid 404 broken link issues. You can also get the page using Get-PnPListItem command to retrieve the page you want to delete, and then use the Remove-PnPListItem command to delete the page.

PowerShell to Delete Multiple SharePoint Online Pages

How about deleting multiple pages from a SharePoint Online site?

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/retail"
#Array for Multiple pages to Delete 
$PagesToDelete = @("Page1.aspx","Page2.aspx","Page3.aspx", "Page4.aspx")

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

#Iterate through each page to delete
ForEach ($PageName in $PagesToDelete)
{
    Try {
        #Get the Page to Delete
        $Page = Get-PnPPage -Identity $PageName -ErrorAction Stop

        #Delete the Page
        Remove-PnPClientSidePage -Identity $Page -Recycle -Force -ErrorAction Stop | Out-Null
        Write-Host "$PageName has been deleted Successfully!" -ForegroundColor Green
    }
    Catch {
        Write-Host $_.Exception.Message -ForegroundColor Red
    }
}

Be sure you replace the parameters with the actual site URL and the page name you want to delete. As a best practice, It is important to make sure that the page you are deleting is not linked to other pages or content, as this can cause broken links and errors.

How to delete a SharePoint page using SharePoint Designer

SharePoint Designer is a nifty tool that can be used to perform various tasks in SharePoint. It can be used to delete a SharePoint page as well. Here are the quick steps involved:

  1. Open SharePoint Designer and open the modern site where the page you want to delete is located.
  2. Click on “Site Pages” (or “All Files”>> SitePages) in the left navigation pane to display all site pages on the site.
  3. Select the page you want to delete and press the “Delete” key on your keyboard. You can also select the file and click the “Delete” button from the ribbon or the context menu.
    sharepoint online how to delete a page
  4. When prompted, confirm that you want to delete the page.

Once you confirm, the page will be deleted, and you will no longer see it in the folder. Note that deleting a page using SharePoint Designer also sends the page to the SharePoint recycle bin.

Wrapping up

In summary, deleting a SharePoint page may seem like a simple task, but it is important to consider the impact on other pages and content before making any changes. By following best practices like having a backup, and checking dependencies, you can effectively manage your SharePoint pages and keep your site organized and efficient. Whether you choose to use the SharePoint interface or PowerShell scripts, the process of deleting a SharePoint page can be simple and straightforward when you know what to do.

What happens when I delete a SharePoint page?

When you delete a SharePoint page, it is moved to the recycle bin. It can be recovered from the recycle bin within a certain time frame – 93 days. After that, it is permanently deleted.

Can I recover a SharePoint page after it has been permanently deleted?

No, it cannot be recovered once a SharePoint page has been permanently deleted.

Can I delete multiple SharePoint pages at once?

Yes, you can delete multiple SharePoint pages at once using PowerShell scripts or using the web browser.

How to remove the page title in SharePoint online?

You must change the page layout to “Home” to remove the page title or header. More info here: How to remove the Page Title in SharePoint Online?

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *