Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • Customization Guides
  • Advanced Customization

How to create custom redirects via JavaScript?

In this guide, we will cover how to create custom redirects directly from the customize section of your Knowledge Base.

Written by Guilherme Arantes

Updated at September 24th, 2024

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Customization
    Customization Guides
  • Article Editor
  • Getting Started
    Managing Users Analytics Content Management Permissions & Accessibility Video Tutorials
  • Integrations
  • API & Webhooks
    API V2 API V3
  • Languages & Translations
  • Authentication
  • Swifty AI
  • Settings
    User Settings User Behavior Knowledge Base Settings Custom Domain
+ More

Custom redirects are redirects that are not covered on the Article Redirects feature, learn more at How to Create Article/URL Redirects. For instance:

  1. Redirects from valid URLs on your KB;
  2. Redirects based on search parameters or event listeners;

In order to redirect users before the page is fully loaded, place the code in the Main Layout file, inside the HEAD tag.

Multilingual KBs

If your Knowledge Base is multilingual, please notice that you have multiple Main Layout files, each one specific to a language section.

 

Example

<script>
if (location.pathname === "/en_US") {
    location.href = "/en_GB";
}
</script>

In this example, we created a redirect from the English (US) language section to the English (UK) section. You might want to use liquid tags to create more robust/complex redirects, learn more at Shopify/Liquid Variables and Objects Reference.

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • How To Archive And Unarchive Content
One Knowledge Base To Replace Them All
24/5 support
Constant Product Updates & Improvements
100% money back guarantee
99.9% Uptime
Features
  • AI Knowledge Base AI-Enabled
  • Helpjuice Extension AI-Enabled
  • Powered Editor AI-Enabled
  • Advanced Analytics AI-Enabled
  • Customizable Themes AI-Enabled
  • Swifty · Helpbar & Chatbot AI-Enabled
  • Multi-Language Support
  • Step-by-Step Tutorial Creator
  • Seamless Integrations
  • User Access Control
  • See All Features >>
Product
  • Product Roadmap
  • Pricing
  • Book a Demo
  • Policies & Security
  • Our Customers
  • About Helpjuice
  • Contact Our Team
Resources
  • Our Knowledge Base
  • Webinars
  • Success Stories
  • API Documentation
  • Data Import Guide
  • Helpjuice Blog
Copyright © 2025, Helpjuice Inc.
Helpjuice, Inc. is a registered US Corporation.
EIN 46-2257741 | Download W9
Made in America High Performer Ease of Use Get Support
Get Started For Free
4.8 average review on
Life’s too short to use mediocre software.
+1 (833) 387 3877
Powered by Helpjuice Helpjuice Swifty AI External Link
Expand