Does anyone know if the SXA navigation component can be made to render links that are not links to pages in the Sitecore site itself? In other words, any kind of external link, or otherwise show links to items within Sitecore in a way that deviates from the hierarchy of the tree it is crawling. Thanks
1 Answer
You can do this with few tweaks.
When you create a site with all modules (features) enabled you can add Page
or Redirect
items under Home.
Redirect
items can already point to any item or external page, our goal is to make them visible in navigation.
One and the only requirement for that is to add _Navigable
to base templates, so.
- Got to your project tenant templates (
/sitecore/templates/Project/F/T/
) - Add new template
External Redirect
- Add following base templates:
{C14B6289-8AC2-439C-9E5B-40DE9F820C3F}|{371D5FBB-5498-4D94-AB2B-E3B70EEBE78C}
(_Navigable
,Redirect
) - Create item using new template.
- Set
Redirection URL
field andLink Caption in Navigation
(remember that your navigation should respect this field in rendering variant)
This is not the perfect solution due to additional redirect, but it works! I used this approach in the past and it worked fine. Actually, I can see advantages of this approach. You are able to track external links clicks or do anything you want. Always see the bright side ;)
-
This doesn't work for links that need to open in a new browser. Commented Oct 28, 2020 at 18:59