Hello devs,
Today I would like to show you how we can create Custom Visualforce Error Page in Experience Cloud (Community Cloud).
Let’s begin!
Demo

Solution overview
We can find two options to set custom error messages.
- Create Custom Visualforce Page and override existing error pages setting using our VF page.
- Edit existing Visualforce error pages
- CommunitiesLogin (Authorization Required Page)
- BandwidthExceeded (Limit Exceeded Page)
- InMaintenance (Maintenance Page)
- FileNotFound (Page Not Found Page)
- Exception (Generic Error Page)
Authorization Required Page—The page users see when trying to access pages for which they do not have authorization.
Salesforce
Limit Exceeded Page—The page users see when your site has exceeded its bandwidth limits.
Maintenance Page—The page users see when your site is down for maintenance.
Service Not Available —The page users see when Salesforce servers are unavailable.
Page Not Found Page—The page users see when trying to access a page that cannot be found.
Generic Error Page—The page users see when encountering generic exceptions.
Solution #1
1. Create Visualforce Page
<apex:page >
<style>
.footer {
height: 100px;
background: black;
color: white;
display: flex;
justify-content: center;
align-items: center;
}
.error-content {
margin: 24px auto;
font-size: 48px;
display: flex;
justify-content: center;
align-items: center;
}
.logo {
height: 60px;
background: black;
display: flex;
justify-content: center;
align-items: center;
}
</style>
<div class="logo">
<apex:image url="{!URLFOR($Resource.ErrorPage, 'img/logo.png')}"/>
</div>
<div class="error-content">
Page not found.
</div>
<div class="footer">
Salesforceprofs.com
</div>
</apex:page>
2. Set Error Page in Sites
- Go to Setup > Sites and Domains > Sites > Select your community by clicking the community name.
- Go to Error Page section > Click Page Page Assignment button and assign your custom VF Error page to a different Error Condition.
Authorization Required Page—The page users see when trying to access pages for which they do not have authorization.
Salesforce
Limit Exceeded Page—The page users see when your site has exceeded its bandwidth limits.
Maintenance Page—The page users see when your site is down for maintenance.
Service Not Available —The page users see when Salesforce servers are unavailable.
Page Not Found Page—The page users see when trying to access a page that cannot be found.
Generic Error Page—The page users see when encountering generic exceptions.


3. Configure a community
Go to Digital Experiences > All Sites > Select workspace next to your community name > Administration > Preferences.
Check Use custom Visualforce error pages.
Click the Save button on the bottom of Preferences.

Was it helpful? Check out our other great posts here.
Resources
- https://help.salesforce.com/articleView?id=sf.sites_error_pages.htm&type=5