0

I need to create page item which should link to external page and also need to be part of the navigation.

To solve this, I created custom external redirect template under templates/projects and I picked standard template, _navigable and redirect from base template.

After doing all this steps, I can create item and assign external URL with option to open in new window. Issue which I am having is that redirect external link is not opening in new page. am I missing any steps? Thanks

1

1)

Your solution won't work until you add some logic for Sitecore / layout / Page that once there is this field on Page it needs to redirect.

Probably this would be a seperate component that will be part of standard values on your custom template.

I assume based on your description that you have currently only field where you specified External link but that's it.

2)

There is a Redirect template that you can use next to standard Pages as you are using SXA.

A redirect is a way to send both users and search engines to a different URL from the one they originally requested. For example, to redirect visitors who enter namewebsite.com/home-a in their browser to namewebsite.com/home-b. This is very useful when you want to redirect a specific page to a new location, change the URL structure of a site so that it appears higher up in the navigation, or even redirect users to another website entirely. You can also use the mapping tool to set up a 301/302 or server transfer redirect.

To add a redirect item:

enter image description here

In the Content Editor, right-click on the page where you want to specify your redirect, and click Insert, Redirect.

Enter a name for the redirect item and click OK.

In the Redirect section, enter the URL that you want to direct to and save your changes.

enter image description here

Taken from Official Sitecore SXA Documentation: https://doc.sitecore.com/users/sxa/18/sitecore-experience-accelerator/en/redirect-a-url.html

It should exactly fulfill your requirements.

-2

You will need to handle this when you generate the link in the navigation.

If you are using Glass.Mapper, you can do something like:

@using (BeginRenderLink(externalRedirectItem, x => x.FieldWithLinkToPage))
{
    @externalRedirectItem.ItemName
}

Or, if you don't have Glass, you can do it with raw Sitecore:

@Html.Sitecore().BeginField("Field With Link To Page", externalRedirectItem)
@externalRedirectItem["Field With Link To Page"]
@Html.Sitecore().EndField()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.