+ Start a Discussion
Aleksey SheldagaevAleksey Sheldagaev 

How to create community page link within Lightning?

I have 'customPage' created in Community Builder and I need to navigate a user to this page from my Lightning component inside other community page.

I've tried to use direct link:
<a href="custom-page">Custom Page</a>
it works, but with browser refreshing, that's not appropriate, I need the same behavior as Top Navigation have.

And I've tried the second approach:
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
  "url": "custom-page",
  "isredirect": true
});
urlEvent.fire();
again, it works, but it opens new tab|window what isn't thery helpful

So, how to handle such simple action within community?
P.S.: I'm using Napili template for my community.
Aleksey SheldagaevAleksey Sheldagaev
still searching a solution...
Florian JoubertFlorian Joubert

Hello Aleksey, 

It's been a while but I have exactly the same problem ! Did you find any solution? 

Thanks

Michael Patterson 15Michael Patterson 15
I believe you need to have a slash in your url for your action to act as the navigation/single page application. So instead of "custom-page" you need "/custom-page".
 
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
  "url": "/custom-page"
});
urlEvent.fire();

 
Olalla Iglesias AlcaláOlalla Iglesias Alcalá
Hello, I have found a solution but is in a VFP I hope i've helped :)
 
<apex:outputLink onclick="navigateToUrl(window.location.origin+'/community-page')" styleClass="button"> Button Label </apex:outputLink>