Custom Community Error Page

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

Custom VF Error Page
Custom VF Error Page

Solution overview

We can find two options to set custom error messages.

  1. Create Custom Visualforce Page and override existing error pages setting using our VF page.
  2. Edit existing Visualforce error pages
    1. CommunitiesLogin (Authorization Required Page)
    2. BandwidthExceeded (Limit Exceeded Page)
    3. InMaintenance (Maintenance Page)
    4. FileNotFound (Page Not Found Page)
    5. Exception (Generic Error Page)

Authorization Required Page—The page users see when trying to access pages for which they do not have authorization.
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.

Salesforce

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

  1. Go to Setup > Sites and Domains > Sites > Select your community by clicking the community name.
  2. 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.
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.

Salesforce
Error Page Assignment Section
Error Page Assignment Section
Assign Error Pages
Assign Error Pages

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.

 Use custom Visualforce error pages
Use custom Visualforce error pages

Was it helpful? Check out our other great posts here.

Resources

  • https://help.salesforce.com/articleView?id=sf.sites_error_pages.htm&type=5
5 3 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Close Menu
0
Would love your thoughts, please comment.x
()
x