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?

bumped to the homepage by Community 2 days ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • Can you please specify why you need this only on one page? What SXA component do you use for links? – Peter Procházka May 19 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 – Alivor Tikos May 19 at 14:23
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, privacy policy and cookie policy

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