Navigation in Salesforce Digital Experiences (sites / communities) LWC

Written by Vikash AgarwalMay 5th, 2022
Navigation in Salesforce Digital Experiences (sites / communities) LWCNavigation in Salesforce Digital Experiences (sites / communities) LWC

I was having issue with NavigationMixin(LightningElement) while working in Salesforce Experience cloud (sites), I was unable to navigate from one site page to another using code. Working snippet of navigating from one site page to other (community and site page example)

Initial Code looks like this :

1let authenticatedUser = await this.callAuthenticationOrAnyother();if (!authenticatedUser) {
2this[NavigationMixin.Navigate]({
3type: "comm__namedPage",
4attributes: {
5name: "Sample1__c"
6}
7});
8}

What are the things I was missing and how I fixed -

  1. Make sure the api name of the site page is exactly same (it’s a case sensitive and make sure you are appending __c in the end of the name just like mentioned above)
image_site_navigationimage_site_navigation
image_site_navigation