Redirecting Old Articles to New Ones Using Custom Scripts

Note:
This is an advanced feature that involves adding custom code to your Help Center.
Currently, we do not offer redirects from one article to another in your Help Center. Instead, you can add a custom script to set up redirects from old URLs on other platforms, to your articles in Wix Answers.

Below is an example script that redirects an old article named "/redirecting-articles-old" to this one. You can copy and paste this code to a custom script.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

answersSdk.onLoad(function () {  

   // here we definea a data structure containing
    // the source and target for our redirects
 var redirectMap = [
        {
   from: '/old-articles-format',
   to: '/article/getting-started-with-your-knowledge-base-articles'
        },
  {
   from: '/article/redirecting-articles',
   to: '/article/redirecting-old-articles-to-new-ones-using-custom-scripts'
        }
 ];
  
    // this function will iteration on the above
    // obj and check if we should perform a (naive) redirect
   function checkForRedirects() {
      redirectMap.forEach(function (obj) {
        var url = location.href;
        if (url.indexOf(obj.from) !== -1) {
          location.href = url.replace(obj.from, obj.to);
        }
      });
    }

 checkForRedirects();

   // as our public is a single page application,
    // we'll need to check for redirects each time a page loads
 answersSdk.addListener(answersSdk.events.pageLoad, function () {
  checkForRedirects();  
 });
});