1

I would like to add class name in redirect url anchor tag. Is it possible ??

Could someone let me know how redirect url create a anchor tag and where is the code of it?

enter image description here

1
  • Agree with @Marek's point here, could you please clarify why you need to add any class here? Commented Apr 22, 2022 at 8:01

2 Answers 2

3

SXA redirects should not be used normally for any links generation. Their purpose is completely different.

When you create a this-url-should-be-redirected redirect item and configure its Redirection URL to some-another-link, when someone tries to open https://yourwebsite/this-url-should-be-redirected, browser will redirect them to https://yourwebsite/some-another-link.

You can read more here: https://doc.sitecore.com/xp/en/users/sxa/17/sitecore-experience-accelerator/redirect-a-url.html

0

To add a class in an anchor tag, Sitecore provides you with the OOTB option to do this. So when you click on the insert link, you can find the option to add a class name

enter image description here

And if you want to do some customization then you have to create your own processor and then need to register this. To know more about this, you can follow these links.

https://stackoverflow.com/questions/27136867/sitecore-how-to-get-the-class-entered-in-general-link-field

https://sitecorejunkie.com/2015/10/10/add-a-custom-attribute-to-the-general-link-field-in-sitecore/

2
  • When I am adding in style class it is not showing in anchor tag which is created by redirects in experience editor .
    – Nisha
    Commented Apr 22, 2022 at 5:38
  • I Added that using experience editor and the output is showing the class. <a href="/amazon/login" data-variantitemid="{C0B095E6-4F35-4208-8209-AAB9446A7BD7}" data-variantfieldname="Link" class="testclass">login</a></div> So I have found one more thing for you. If you are using a rendering variant. Follow this article sitecore.stackexchange.com/questions/16508/… Commented Apr 22, 2022 at 6:19

Your Answer

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

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