Change Landing Page of Community Website

|
| By Webner

Change landing page of community instead of showing default home page

We can change default landing page in CommunitiesLandingController. CommunitiesLandingPage is the Active Site Home Page for your community, meaning that it is shown when someone enters a direct URL to your community.

Steps to update the CommunitiesLandingController code to redirect to the new page:

  • Click Setup.
  • Enter Apex classes in quick find box and click it.
  • Find CommunitiesLandingController and click Edit.
  • The default code of CommunitiesLandingController :
/**
 * An apex page controller that takes the user to the right start page based on credentials or lack thereof
 */
public with sharing class CommunitiesLandingController {
    // Code we will invoke on page load.
    public PageReference forwardToStartPage() {
        return Network.communitiesLanding();
    }    
    public CommunitiesLandingController() {}
}

The new code will be:-
/**
 * An apex page controller that takes the user to the right start page based on credentials or lack thereof
 */
public with sharing class CommunitiesLandingController {
    
    // Code we will invoke on page load.
    public PageReference forwardToStartPage() {
    String communityUrl = 'https://google.com'; //URL of new page
     return new PageReference(communityUrl);   
   }
    
    public CommunitiesLandingController() {}
}

Click Save.
When a user enters the community URL, they see the new Active Site Home Page after login.

Leave a Reply

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