How to Redirect a Knowledge Base Page

Redirecting a Knowledge Base (KB) page allows you to add flexibility to your articles or forms easily. For example, imagine you've already created a privacy policy page on your company's website. Instead of recreating this page in a KB article within Kustomer - you'd like to redirect the customer to your existing page. We can easily avoid this hassle by adding a single file to your KB theme.

Before starting, while you can configure a redirect without knowing how to code, we will add and modify a few lines of simple code to your theme. The process is very straightforward, and you'll be redirecting articles in no time!

You can skip to the next section if you already know which theme you want to edit. To ensure we are making changes to the theme currently being used by your knowledge base, navigate to Settings > Knowledge Base > Configuration. At the top of this page will be a brand selector with a dropdown containing all the brands in your Kustomer instance. Double-check the brand here, making sure the brand you wish to make updates to is selected. Next, look at the 'Theme' section. The theme selected currently is the default theme for the brand you selected; note the name, as this is the theme we will be updating.

Once you know which theme needs to be updated, navigate to Settings > Knowledge Base > Themes and open the theme we found in the previous section. A preview of your current theme will load in the visual editor, go ahead and click 'Create New Draft' at the top of the preview pane. For the changes we will be making, we will need to open the code editor by clicking the menu button (three dots) then select 'Go To Code Editor' from the menu that appears.

Note: If you see 'Create Draft' instead of 'Save Draft' create a new draft before opening the code editor.

You should now see a blank page displaying 'No file selected.' You can find all the files that make up your theme on the right of the code editor. We won't be editing any of these, but for context, there are three types of files:

  • Pages - the different pages that make up your Knowledge Base (Articles, Homepage, etc.)

  • Components - Components are files are used to build pages and can be pulled into different pages.

  • Globals - Files accessible by the Knowledge Base globally, meaning any page can access these files. We will be creating a global file to redirect our pages.

Click 'Add Files' at the top of the Theme Files pane to create our redirect. When the 'Create Theme File' window appears, create a file using the following options:

  • Theme Target: Global

  • File Name:  redirect

  • File Type: JS

Note: Do not add an extension to the file name; the last option will add the file type.

Scroll down to the Globals section of the Theme Files pane and open our newly created redirect.js file. In the new file, paste the following code:

if (window.location.href.includes('leave-this-page')) { window.location.href = '' };

Next, we will edit the code to redirect a KB article.

In the parenthesis after window.location.href.includes (first line), replace the text inside the quotation marks with the slug of the article you wish to redirect. You can find the slug for an article on the article editor page at the top of the article. 

Then replace the with the URL of the page you will redirect the article.

Once you’ve updated the code in the redirect.js global file, save and publish the draft. Now preview your theme and navigate to the article you configured the redirect for. When the article loads, you should be redirected to the URL you entered.

If you are not redirected, double-check the theme to ensure you have published your changes. Next, check the code in the redirect file.


Redirects can be used for forms or whole categories by changing the text after “includes” to the form’s slug or the categories subdomain. Additionally, if you need multiple redirects, you can paste the same code under your initial redirect to redirect as many articles as needed.

If you run into any issues or need assistance configuring your redirect, reach out to Kustomer support via chat or email at any time!