Redirecting traffic from deleted help center articles

Return to top

55 Comments

  • Spencer Fleury

    So we've been using this code for a long time, and today it suddenly stopped working. We haven't modified our template in any way recently, other than to add more articles to var oldIDS and var newIDs. Has anyone else had this experience?

    2
  • Greg Katechis
    Zendesk Developer Advocacy

    Hi Josh! I took a look at your help center and it is pretty heavily customized, so I'm assuming that's the reason that you're not seeing it. I would recommend talking to the devs that built that to see how they developed it to see if they can steer you in the right direction. As it stands, it really wouldn't be possible for me to tell you how to proceed in this situation, so they will be your best bet!

    1
  • CJ Johnson

    Boris Fernandez I just double checked my setup, and it's working currently with the above example code, even without this line in the script.js: 

    $(document).ready(function()

    One thing I can think of that might be causing this to not work as expected, is that you may need to check that your script.js file is valid code syntax. If it has a syntax error, it will break the file and not fire the contents correctly. I can see that GoGet Support up there for example, if I try to visit the URL they are trying to redirect to, I can see the script.js has a syntax error on line 5, which is probably why this is not working for them. You can see in the dev console, if the script.js throws an error when the page loads.

    1
  • Boris Fernandez
    Don't think that solution works anymore. eg. I do not have that part on our script.js file :

    $(document).ready(function() {
    1
  • Bailey McWhorter

    Do archived articles change the analytics in Explore?

    For instance, if I have a report that shows the total # of articles views and I remove one article that had 100 views, does the report show the total #of article views drop by 100? Or does it keep track of all article views, regardless of whether they are archived? How about deleted?

    1
  • Aakash Gill

    Hi,

    I added the code as suggested, and it is redirecting well.

    The only issue I'm facing is the "flickering". I see the "old" article content for some milliseconds, and then it redirects to the new article.

    Any solution to resolve this?


    Thanks 

    1
  • Dinos Papoulias

    So sad there isn’t a good solution for this after all these years. It’s been requested so many times. Even HelpScout with so much less functionality has a better redirect system.

    1
  • Wasabi

    How can I setup redirects from an article on a different brand? Also, following this guide isn’t working for me; it’s requiring a login when accessing the old article because it’s trying to access Zendesk admin for that article

    1
  • Boris Fernandez

    CJ Johnson  cannot make it work. Actually no error from the JS on the dev console. Not sure what I am doing wrong.

    When you say you do not need the function, how do you input the code in the script.js ? 
    I tested the error_page.hbs also to see if I could miss something but nothing off there too... 

    Everything looks pretty straight forward though...

    1
  • Sally Anne Dishong

    Thank you, Gab. So...the examples are for deleted articles. We generally do not delete articles as our practice. Is there a similar way to redirect archived articles as well?

    1
  • Sawako Kubo

    Greg-Katechis

    no errors

    0
  • Gab
    Zendesk Customer Care
    Hi Stacie, 
     
    That code can be found on line 5 of the Copenhagen theme. 
     

     
     
    Hi Sally, 
     
    I'm afraid there's is no way to check for broken links.
     
    You can also check on this Community post here where there's been a few people asking about it as well: https://support.zendesk.com/hc/en-us/community/posts/115007417707-Managing-Links 
     
    Furthermore, the examples provided in this article are for deleted articles. 
    0
  • Jules

    Hello,

    I would like to redirect untranslated articles to the default language article.

    For example, my default language is English and I have French translation. If the French translation does not exist for an article, the user who selects French, is currently redirected to the French home page. But I would like him to be redirected to the English article.

    I tried the code bellow but it doesn't change anything...

    $(document).ready(function () {
    var notDefaultLanguage = window.location.href.indexOf('/en-us/') == -1;
    var isArticle = window.location.href.indexOf('/articles/') > -1;
    var isErrorPage = $("#error-page").length > 0;
     
    if (isArticle && notDefaultLanguage && isErrorPage) {
    var newURL = window.location.href.replace(/(.*\/hc\/)([\w-]+)(\/.*)/, "$1en-us$3");
    window.location.href = newURL;
    }
    });
     
    Any idea to help?
    0
  • Sebastian

    Yes, that's correct. I missed that it wasn't inside.

    0
  • Sally Anne Dishong

    Also, does this code work for archived articles as well as deleted articles?

    0
  • Carlo

    Hi, we followed the instructions in the article above to redirect the untranslated article to the original article in English. However, it seems it's not working: this is an article in English that is not translated in German, but if you switch the language to German it redirects you to the home page instead of showing yout the article in English: https://zakeke.zendesk.com/hc/en-us/articles/4514828443932-Test-for-fallback

    What's wrong?

    Thanks
    Carlo

     

    0
  • Josh H

    Hey Greg-Katechis,

    I look in our script.js file and it doesn't have the below line:

    $(document).ready(function() {

    If that's missing, can we simply add it? Do you know which line would be the best place to add it? Thank you.

    0
  • Stacie Loving

    Hello,

    I'm using the Copenhagen theme (2.19.4) and nowhere in the script.js file do I see anything similar to:

    $(document).ready(function() { 

    Do I just add the redirect to the file? Does it need to be at the top of the file or is it ok to append to the bottom?

    Thanks

    0
  • Kay
    Community Moderator

    Hi David,

    For a hostmapped domain (example: cocacola.com/help) you can set-up a 301 Redirect via a .htaccess file.

    Using the .htaccess method won't impact your SEO. The JS redirect might have impact on your SEO.
    From an SEO point of view, a JavaScript redirect is not the most optimal way of redirecting because search engines need to render a page to find the redirectRedirecting using a 301 redirect is always recommended (except if you're looking to temporarily redirect)

    Articles still have the same ID
    If your articles still have the same ID, then you need 1 redirect line.

    Articles with changed IDs
    You will need a single redirect line for each article if your articles no longer have the same article ID.
    0
  • Anindita Samajpati

    Hi Elizabeth Brown and Philip Addison

    While you are waiting for Zendesk team to respond, I can share my experience here. For me, the code only worked when I archived the old articles. "Unpublishing" the old article led to a redirect to an authentication page and not to the new article.

    I haven't tried deleting an article and redirecting it yet, so cannot comment on this part.

    Best,

    Ani

    0
  • Devan La Spisa
    Zendesk Community Manager

    Hello @...,

    This article's information with some changes to fit your use case is the best documentation we have available for this ask. I'll reach out to our moderator team to see if they can offer son insight into making these changes. We'll also share this post in our weekly digest so others can share that advice on how to accomplish this. 

    Best regards. 

    0
  • CJ Johnson

    Here's what mine looks like: 

    The error.hbs template would also require that you put the code inside some HTML script tags, as the template is a Handlebars file.  In script.js, this isn't necessary, since it's a javascript file. 

     

    Edit: Also, for whatever reason, it took like a solid half hour to hour for the code to start working when I deployed it the first time. I posted higher up in the thread about it, I kept trying to "fix" it when it turned out it was already working and it I had just stopped fussing at it, it would've started working after a bit. Just throwing that out there because I forgot about the weird long wait and it made me think the code didn't work either! 

    0
  • Spencer Fleury

    Hello—I've had success with this workaround on the article level, but is there any way to make it work for anchor links? As our Help Center grows and evolves, the internal structure of the articles will often change, and headers (which have those anchors) will be deleted or moved to other articles, etc. But there are still links out there in the wild that point to these anchored links, and I'd like to be able to ensure they are redirected to where they need to be.

    (Also, why is this so challenging in Guide? Every other CMS I've worked with supports redirects a lot more efficiently than this. Are there plans to enhance this?)

    0
  • mfg

    To answer my question above, you can accomplish redirecting from one form to another with the same method and a few adjustments:


    //form redirect

      var oldIds = ["12500176350359", "12500154221847"]; //form IDs to be directed from

        var newIds = ["12500185961751", "12552908256535"]; //form IDs to be directed to

        for (var i = 0; i < oldIds.length; i++){

          if (window.location.href.indexOf(oldIds[i]) > -1) {

            window.location.href = 'https://[YOURSUBDOMAIN].zendesk.com/hc/en-us/requests/new?ticket_form_id=' + newIds[i];

                }

        } 

    //end form redirect
     Notes about snippet above:
    • for existing, active forms the page will load with the initial form parameter then update to the new parameter (including when the initial form is selected from list)
    • for existing, deactivated form, the page will load to the new parameter
    • for non-existing forms, page will load like normal - will load with no form selected
    • old/new ID array item counts need to match or redirect seems to fail on the element missing a twin
    • Redirect method above preserves prefilled form URL parameters including on custom fields
    • Seems a better end user experience to deactivate forms - faster load time, no visible changes.

     

    0
  • Elizabeth Brown

    Hi Zendesk team - does this option work with archived articles at all? or do I have to delete an article before I can go through the process of redirecting the URL? 

    I'd prefer archiving, just in case I want to re-work content later. 

    Please advise? 

    Cheers

    E.A. Brown

    0
  • Product Team

    Honestly, I am in awe that the Zendesk product team considered this release ready.

    It's unreasonable to expect your users—help docs and technical writers—to have to know JavaScript to configure basic redirects for duplicate or obsolete pages. This is functionality that should have had a full WYSIWYG decade ago in the platform. 

    0
  • Wilson Ho

    I am trying to redirect all broken links to my home page, would method 3 work for this? I tired and just entered in the homepage address instead of a specific article but its not working. 

    0
  • Sabra
    Zendesk Customer Care

    Bailey McWhorter - I believe Julio had Google Translate enabled when he took the screenshot, and while Google does it's best, it doesn't always get the technical terms for Explore quite right. which is why the name of the attributes aren't matching up exactly. Interaction ID should be Engagement ID and Item ID should be Article ID. 

    Aakash Gill - while I don't have a solution for the page flickering due to redirects, perhaps others have found a way help mitigate this and can chime in with anything custom they have done!

    0
  • Greg Katechis
    Zendesk Developer Advocacy
    And are you seeing any errors in the console that may help this situation?
    0
  • Julio H
    Zendesk Customer Care
    Hi Bailey,
     
    Thanks for your feedback.

    Archived articles will continue showing and be counted in Explore. Only the team publishing dataset. 


     
    In the other dataset, for example, Knowledge base. In the viewed article metric, you will not be able to see the title or information about delete or archived articles, but you will be able to see the number of times those articles were viewed. 
    Articles viewed The number of articles that have been viewed at least once. Each article is counted only once, even if it is viewed multiple times.
    You can see a number 4 in the screenshot below, because of the articles deleted or archived. 


     
     
    Adding the metric interaction ID, I can see the ID of those deleted or archived articles. 


     
    For more information, please visit: Metrics and attributes for Zendesk Guide 

    I hope it helps! 

    Greetings. 
    0

Please sign in to leave a comment.

Powered by Zendesk