Route Link

forceCommunity:routeLink

Sets an HTML anchor tag with an href attribute that’s automatically generated from the provided record ID. Use forceCommunity:routeLink to improve SEO link equity in template-based communities.

For Use In

Experience Builder Sites

Because the href attribute is automatically generated from the provided record ID, forceCommunity:routeLink is only suitable for creating internal links to recordId-based pages in your Experience Builder site, such as the Article Detail or the Case Detail pages.

Internal links help establish an SEO-friendly site hierarchy and spread link equity (or link juice) to your Experience Builder site’s pages.

Here’s an example of a forceCommunity:routeLink component.

1<aura:component implements="forceCommunity:availableForAllPageTypes">
2    <aura:attribute name="recordId" type="String" default="500xx000000YkvU" />
3    <aura:attribute name="routeInput" type="Map"/>
4    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
5    <forceCommunity:routeLink id="myCaseId" class="caseClass" title="My Case Tooltip" label="My Case Link Text" routeInput="{!v.routeInput}" onClick="{!c.onClick}"/>
6</aura:component>

To create the link, the client-side controller sets the record ID on the routeInput attribute during initialization. Clicking the link enables you to navigate to the record page.

1({
2  doInit: function (component, event, helper) {
3    component.set("v.routeInput", { recordId: component.get("v.recordId") });
4  },
5
6  onClick: function (component, event, helper) {
7    var navEvt = $A.get("e.force:navigateToSObject");
8    navEvt.setParams({
9      recordId: component.get("v.recordId"),
10    });
11    navEvt.fire();
12  },
13});

The previous example renders the following anchor tag:

1<a
2  class="caseClass"
3  href="/myCommunity/s/case/500xx000000YkvU/mycase"
4  id="myCaseId"
5  title="My Case Tooltip"
6>
7   My Case Link Text
8</a>

Attributes 

NameDescriptionTypeDefaultRequired
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]
classA CSS class for the anchor tag.String
idThe ID of the anchor tag.String
labelThe text displayed in the link.String
onClickAction to trigger when the anchor is clicked.Aura.Action
routeInputThe map of dynamic parameters that create the link. Only recordId-based routes are supported.Map
titleThe text to display for the link tooltip.String