How to Fix Links Inserted via a WYSIWIG Editor in Kentico 12

   —   

When using a Rich text editor form control for your page type fields, it is possible to add links to other content-only pages using the Insert/Edit link option of the WYSIWYG editor. After you move your site to a different environment, these links will break unless you apply our hotfix package.

This behavior is caused by the fact that these links are absolute URLs. It means that the URLs also contain a domain name, which matches the presentation URL. The Kentico 12.0.26 hotfix package repairs the dialog to insert links to content-only pages in a relative form (~/page). 

Plus, it introduces an output processor which inspects the HTML output of MVC pages and resolves relative URLs (leading with ~). This way you can ensure all links are valid incase the Html.Kentico().ResolveUrls() call was omitted for rich text content in views.

Optional Opt-out from Automatic URL Resolving

You can opt-out from automatic URL resolving by adding <add key="CMSMVCResolveRelativeUrls" value="false" /> app key in the MVC site's web.config file. Do so:

  • if the way the output processor works doesn't fit nature of your content
  • if you have performance concerns: additional processing of a whole page source has a marginal performance hurt

Once you have disabled the output processor, it is necessary to ensure relative links resolve manually using Html.Kentico().ResolveUrls(). You can find further information in our documentation.

How to Fix Existing Links

Existing pages are not affected by the hotfix. Therefore, after applying the hotfix you will need to to manually repair existing inserted links. Check out the below instructions to learn how to repair links in existing content:

  • download this ZIP file 
  • the archive contains project folder, unzip it and open in Visual Studio
  • add a connection string to your database to app.config file
  • compile and run the project
  • application will list all suspicious objects (pages, SKUs) which may contain relative links in the following format: Page ‘node_alias_path’ field 'field_name' in culture 'culture_code' for pages, and: SKU ‘SKU_name’ field 'field_name' for SKUs

2019-06-10-12_58_21-C__Users_RadekP_Downloads_KenticoAbsolutePageLinksDetector-(1)_KenticoAbsolutePa.png

  • in the Pages application it is then necessary for each page of the listed pages to navigate to the Content tab, locate the field, identify the link and re-selected the linked page again. For SKUs - repeat the same process via the Products application
  • run the application again and verify that the list of identified pages and SKUs is empty
Share this article on   LinkedIn

Lukáš Gancarčík

Senior Support Specialist - Content Management