How do I redirect a knowledgebase article to an external URL?

Answered

11 Comments

  • Vladan Jovic
    Comment actions Permalink

    Hey David, this code snippet should be what you're looking for:

    <script type="text/javascript">
        if(window.location.href.indexOf("/123456789") > -1) {
           window.location.href = "http://google.com";
    } </script>

    You just need to paste this code at Document Head of your Help Centre theme template. Also, don't forget to:

    - replace 123456789 with your article ID,
    - replace http://google.com with your external site page URL.

    Cheers!

    1
  • David A.
    Comment actions Permalink

    Thanks, Vladan! Although, it doesn't appear to be working. I tried this through our test theme. I've added the code to the "document_head.hbs" file, and replaced the article ID and external URL, but redirect does not happen within the test theme.

    0
  • Vladan Jovic
    Comment actions Permalink

    Ahh sorry, my bad,

    instead of 

    "/123456789/"

    it should be

    "/123456789"

    I just updated my original comment, and it will be visible shortly again.

    0
  • David A.
    Comment actions Permalink

    No worries. It now works like a charm. Thank you, Vladan.

    1
  • eefrati
    Comment actions Permalink

    Hey Vladan,

    I've been sifting through the different threads on this topic, but I think this is what I need. My content team is trying to migrate a long list of retired help desk articles (currently sitting on help.freightos.com) to an external link, i.e. freightos.com/xyz. 

    Just to confirm, is the above solution for individual articles? And where is it that we should actually past that code? 

    0
  • Vladan Jovic
    Comment actions Permalink

    Hey eefrati, welcome to the Community! 

    Yes, this will work in case you want to redirect all your current articles. The code can be placed in the document head and you need this code for each article. 

    Just one thing, If you need to move the whole knowledge base I will not recommend this solution cause of the SEO things.

     

    0
  • Paul
    Comment actions Permalink

    Would this be a recommended way to redirect old articles in help center to a new article?  for example

     

    <script type="text/javascript">
        if(window.location.href.indexOf("/123456789") > -1) {
           window.location.href = "/123456999";
    } </script>

    Where 123456789 is old article, and 123456999 is new article.

    OR does guide have a better way to rediret articles?
    0
  • Vladan Jovic
    Comment actions Permalink

    Hey Paul, similar but maybe better/more scalable way:

    https://cl.ly/b6bf7e98e9c5

    Source: https://support.zendesk.com/hc/en-us/articles/217958367-Redirecting-traffic-from-deleted-Help-Center-articles

     

    0
  • Nicole - Community Manager
    Comment actions Permalink

    Hi Paul,

    I checked in with our Customer Advocates, and they said this:

    "The comment is accurate, but you need the full url rather than just the article number. But that JavaScript should work, just throw it in the header."

    So it would be:

    <script type="text/javascript">if(window.location.href.indexOf("article url") > -1) { window.location.href = "(article url";}</script>

    0
  • Scott Havard
    Comment actions Permalink

    Hi all!

    Like everyone else, I really need redirection functionality. While I prefer a 30x redirect, this isn't currently possible so, similar to the folks above, I have built a javascript workaround that I would like to share. 

    https://github.com/scotthavard92/Zendesk-Help-Center-Redirection

    The instructions are in the repository, but it largely involves the same procedure as the solutions above. Throw the snippet into your <head>, which is [in most cases] located in the document_head.hbs file. 

    Ideally this is a little more scaleable than looping through every redirection option because I used a hash map instead. So based on an old article ID it will look up a new article ID, and not loop through every option.

    The list is also easier to maintain, as it maps out cleanly:

    old id 1 = new id 1, old id 2 = new id 2, etc.

    Feel free to reach out with any questions!

    0
  • Jessie Schutz
    Comment actions Permalink

    Hi Scott! Thank you so much for sharing this! I'm sure a lot of people will find it useful.

    If you've got a minute, it would be great if you could post a Community Tip on this, perhaps with a more detailed walkthrough of how to implement for folks who aren't as familiar with custom code and using GitHub. If you do, you'll get a gift from us! :)

    0

Please sign in to leave a comment.

Powered by Zendesk