0

We are using Sitecore 9.0.2 & SXA 1.7.1 and we need to update all links to be absolute only in a specific page as by default all the links are relative for example this is the default link

<a title="xyz" href="about/index.html">sometext </a>

We want the link to appear like this

<a title="xyz" href="https://domainname/about/index.html">sometext</a>

We can't do includeserverURL to true as this will affect the entire system.

Is there a pipeline that can be overridden to update links to be absolute for a specific page?

2
  • Can you please specify why you need this only on one page? What SXA component do you use for links? May 19, 2019 at 14:13
  • This page will be used by some external website to provide same header & footer as main site and we are using SXA navigation components May 19, 2019 at 14:23

1 Answer 1

1

The reason to do this still feels rather strange, but if you want to accomplish this there are solutions.

To change the way urls are generated, you need to use a custom LinkProvider. You can create this and define them per site in SXA: https://doc.sitecore.com/developers/sxa/17/sitecore-experience-accelerator/en/add-and-select-a-custom-link-provider.html

In your case you could create a linkprovider that sets the link options to include the domain on certain conditions (alwaysIncludeServerUrl = true). Make sure to fallback to the defaults asap - if this code is not performing well your whole site will suffer.

The condition in the linkprovider could be your page but that might be a rather hardcoded solution. You could also consider using a different device for the external sites that fetch your data and test on that in the linkprovider.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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