Redirecting traffic from deleted Help Center articles

Have more questions? Submit a request

39 Comments

  • Aswin Kannan
    Comment actions Permalink

    Hi all - I'm trying to use the script for "Redirecting untranslated articles to an existing language", but it doesn't seem to work. I still get the error page instead of being redirected. Has anyone had success?

    Is it because the code has error-page but the template is error_page.hbs? I swapped the hyphen with an underscore and it doesn't make a difference.

    var isErrorPage = $(".error-page").length > 0;
    
    0
  • Simon Celen
    Comment actions Permalink

    Hi Aswin,

    In the default Copenhagen theme there is an element with "error-page" class on the error_page.hbs. If you're using an older or customized theme then it may not be there. Open up your error_page.hbs template and add f.e.:

    <span class="error-page"></span>

    If that doesn't help then it's probably not working due to an other issue. Feel free to paste a link to your Help Center and I'll take a look.

    0
  • Aswin Kannan
    Comment actions Permalink

    Thank you, Simon. We are using a customized theme built on top of Copenhagen. Our help center is help.cricut.com.

    0
  • Simon Celen
    Comment actions Permalink

    Hi Aswin,

    Your error_page.hbs file doesn't have the required class I mentioned. 

    The snippet I pasted earlier should work but it's probably better to change the javascript instead:

    var isErrorPage = $("#error-page").length > 0;  // # instead of .

    Note that there may be other issues preventing the redirects to work but this is definitely one of them.

     

    Hope that helps.

    Simon

    0
  • Aswin Kannan
    Comment actions Permalink

    I have made that change in our sandbox, but it doesn't seem to work either. I wish there was an easier way from the Zendesk Guide side. Just a checkbox that says "Fall back on default language for missing translations". Thanks so much for trying! :)

    0
  • Simon Celen
    Comment actions Permalink

    Hi Aswin,

    Could you link me to your sandbox so I can take a look? Thanks

    0
  • Aswin Kannan
    Comment actions Permalink

    Simon - Our sandbox has different themes under construction, so it will be messy. But the change that you have suggested is available in our production now (help.cricut.com). Feel free to take a look again. Thanks a bunch for your help! :)

    0
  • Simon Celen
    Comment actions Permalink

    Hi Aswin,

    I see what's going on, the code should only run on dom ready:


    $(document).ready(function () {
    /* Start of redirecting untranslated articles to English */
    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;
    }
    /* End of redirecting untranslated articles to English */

    //Up Arrow
    // browser window scroll (in pixels) after which the "back to top" link is shown

    ... snip ...

    That should do it.

     

    Simon

    1
  • Aswin Kannan
    Comment actions Permalink

    This is now working perfectly! You are a rockstar! THANK YOU!

    0

Please sign in to leave a comment.

Powered by Zendesk