Help center templating cookbook

Return to top


  • Catherine Michalak


    Is there anyone who could help me add subsections to my custom HC code?

    I am struggling to get the section with subsections to show if it doesn't have an article in it (ie. the subsections have articles but until there's an article in the section itself, it doesn't show on the category page) and struggling to keep the layout the same on the section with subsections level as it is on the category with sections level.




  • Emelie Stjernquist

    Hello @...,

    Just so I get it right, you wish to display an "empty" section?

    I'm not sure that that is possible to do (at least I've not manage to do that), however I have a suggested work-around which is to:

    1. Create an Article on the Section you wish to display (one that is OK to find if found via search function)
    2. Create a custom Section-template where you modify the html, remove the part that displays/list the articles - Guide from Zendesk help
    3. Edit the Section and assign the new template and publish the Section and Article

    I usually elaborate, test back and forth in the templates until I get the result I want. You can also preview it in "Preview mode" before publishing it.


    I hope this helps you to get closer to what you wish to accomplish, good luck!


  • Francois Spinnael

    The trick isn't working. 

    I'm using this list:

    And for some reason, the rename of the "language" is working for English (World) that is defined as a "Variant" but all the other ones, aren't working (Estonia, Lithuania, Latvia, Luxembourg,...)

    <button class="dropdown-toggle" aria-haspopup="true">
    {{#is 'English (Luxembourg)'}}
  • Augusto Silva
    Zendesk Engineering

    Hey @...

    Try something like this instead (language names can change):

    {{#contains current_locale.url "/en-us"}}
  • blak3r

    My Activities has `{{requests}}` template variable on it.  The Home Page does not.  Is there a simple way to expose the `{{requests}}` to the home page for signed in users?

    I'd like to show them their 5 most recent requests on the homepage so it's more visible.

    If that cannot be done, could a Custom Page do this?  Essentially I want a landing page from our product for support that has both their requests and then knowledge base shown under it.  One stop landing page from my product.  We use SSO so our users are already authenticated when going there from the app.

  • Greg Katechis
    Zendesk Developer Advocacy

    Hi Blake! I thought about this for a bit to see if I could get creative, but there isn't any way that I could envision where this could be accomplished. As you noted, `{{requests}}` don't exist in the home page template and custom pages also do not contain that helper. I wish I had better news and if I think of anything, I'll drop you a line here.

  • blak3r

    Greg-Katechis - thanks for giving it some thought.  I suppose this would need to be accomplished with custom javascript to call an api endpoint we'd host that would then use the REST api and return the data back.  Blockers here: 1) simple documentation showing how to add javascript that invokes web requests to a third party server 2) Any tips on how we could authenticate on our server code that the user account is in fact authenticated... like if we had /api/getTickets?user=<emailAddress> we need to verify the user is in fact logged into zendesk somehow so they couldn't exploit the api to get other peoples tickets. 

  • Greg Katechis
    Zendesk Developer Advocacy

    1) For this, you could just make an AJAX request from the custom code in your help center to initiate this call to your server/middleware. While it isn't the exact scenario that you're looking to accomplish, this article should give the basic framework that you would need and then you can just swap out your URL/endpoint.

    2) This one is giving me all sorts of problems...both from a basic implementation standpoint, but especially from a security standpoint. We don't have any method of using OAuth in Guide, which would be the easiest way to accomplish this. You could also use the signed_in helper to confirm that someone is signed in and then grab the CSRF token to do...something clever? Like I mentioned, I don't feel comfortable with this, but maybe the idea would spark something in someone else to a function solution!

  • blak3r

    Thanks Greg. Appreciate the link and the quick response. Maybe I can get a value that is set by the login to uniquely identify the session or something. I’ll hack around. I could provide a token in the return_to portion of the jwt flow. Then modify every page template to store that token in a cookie. And pass that along with server Ajax calls and of course have that same token stored in the user db for checking against. Or maybe just the primary entry point page and have it only work if they redirected there. I’ll sleep on it.

  • Greg Katechis
    Zendesk Developer Advocacy

    Oh that's a great idea if you use JWT! I wouldn't recommend storing the token in the DB, as that will change on each login, but you could use the shared secret from Zendesk to verify the signature on your server. The JTI might cause a problem, although if you're just storing that as a cookie and not doing any authentication/authorization in the traditional sense, this could work.

    Let me know if you get this working or hit any snags with this. This could be a great tip for other users looking for a similar solution!

  • blak3r

    It appears the jwt token is stored in an object in ```Session Storage.z2_sunco_widget_auth.jwt```

    So, in the requests to our server we could include the users email, jwt, and the JTI.  The server would take the JTI and resign the payload.  If that payload matched the jwt supplied with the request then we could assume that the user was in fact the email provided to the request.

    In terms of how to get the JTI, there are two approaches I see... 
    1. Store the JTI in our user table each time a request is built... Con here is possible synchronization issues. For example, we were planning on having links in our product just include the jwt to avoid any perceived glitchy redirect behavior from enduser standpoint.  For example to go to /hc/article/103 our link would be<token>&return_to=

    2. Pass the JTI as a GET param in the return_to and store that to a cookie with custom Javascript code on each page template.  CON here is long urls look gross and add potential for user to bookmark a link with a JTI in it... Probably could mitigate this by updating the url.  

    3. Get our helpdesk working on a subdomain of our domain.  Use instead of https://<zdsubdomain> and have our webapp set a cookie to root domain that the zendesk code could also see. Probably the best option.

    Questions for you... is this z2_sunco_widget_auth a reliable key for the JWT token?  That sunco part is throwing me off.  Also, I'm not a JWT security specialist, I can't see why having the JTI exposed would be that insecure... given you can't sign a payload without the shared secret but maybe i'm missing something.  Feel free to DM me personally if you prefer.

  • Maxim Ageev | null | null

    I need to disable search indexing on the zendesk subdomain. 
    To only allow it on our company domain.
    I would like to add in header template the following line <meta name="robots" content="noindex">
    But only if the domain is helpcenter. Is there a variable in a template that stores the current domain?


  • Katrina Greeves

    Is it possible to filter search results by label? 


    Article 1 is labelled A
    Article 2 is labelled B
    Article 3 is labelled A C

    I'd like to add a sidebar filter for each label. 

    If I select filter A, I will only then see articles 1 and 3.

  • Dave Dyson
    Hi Katrina, 
    There isn't currently a way to filter by label, although articles with labels matching the search terms will be featured higher in the search results. If you'd like to suggest this to our product team, please post your use case to our Feedback - Help Center (Guide) topic, using this template. Thanks!
  • Taehyoung Kim

    Hi, I'm trying to add the content tag feature in our customized template (Copenhagen 1.8.1) but facing some problems.

    I have successfully added content tags in our knowledge base article, but still figuring out how to add them to the search result. I'm basically having a look at search_results.hbs of the recent release. But if I add the lines here to my old template, it said that 'content_tag_filters' does not exist. Does the variable name differ from version to version? Is there a way to implement this on Copenhagen 1.8.1?

    Thanks in advance :)


  • Beth

    I'm having the same issue as Taehyoung Kim above. Appreciate any help - thank you!

  • Christian de Heij

    Having the same for my template content_tag_filters does not exists. Any help to get it in?

  • Sabine Hanna

    Same here regarding the content_tag_filters. Any help would be appreciated!

  • mfg

    blak3r - were you able to solve for securely getting the requests on a separate/home page without exposing tickets the authenticated user shouldn't have access to?

    We are looking to have something similar (buttons for the forms at the top, [requests | article list] in a flex box beneath. Without that "{{requests}}" helper, the current solution we're considering is an iFrame / EMBED SRC= , and then style with CSS. It works - but it's not as secure as we'd like.

  • Dane
    Zendesk Engineering
    Hi All, 

    The current version of Copenhagen is Theme version 2.19.4. I have tried the content_tag_filters on search_results.hbs and it worked without any issues. Unfortunately, as customization is outside our scope the best option is to use the lates version of the Copenhagen Theme.
  • Gorka Cardona-Lauridsen
    Zendesk Product Manager

    Hi All, 

    We are conducting research to improve our Help Center developer experience and would love to talk to any of you that have tried to edit Help Center theme code.

    If you are interested please answer sign up here and answer the 3 survey questions. I will reach out to you to setup a 30 min Zoom call.

    The interview will be a semi-structured interview where we would like to hear you take us through examples of what you have done or tried to do with customizations and your experience with the tools, documentation etc. you used.

    Looking forward to talking to all of you.

    Gorka Cardona-Lauridsen
    Sr. Product Manager, Zendesk Guide 

  • Tomas M. Parra

    I'm trying to add a snippet of each article's body underneath the articles' title in the category page. 
    This is the code as is: 
    <ul class="article-list">
                    {{#each articles}}
                      <li class="article-list-item{{#if promoted}} article-promoted{{/if}}">
                        {{#if promoted}}
                          <svg xmlns="" width="12" height="12" focusable="false" viewBox="0 0 12 12" class="icon-star" title="{{t 'promoted'}}">
                            <path fill="currentColor" d="M2.88 11.73c-.19 0-.39-.06-.55-.18a.938.938 0 01-.37-1.01l.8-3L.35 5.57a.938.938 0 01-.3-1.03c.12-.37.45-.63.85-.65L4 3.73 5.12.83c.14-.37.49-.61.88-.61s. 3.73l3.11.17a.946.946 0 01.55 1.68L9.24 7.53l.8 3a.95.95 0 01-1.43 1.04L6 9.88l-2.61 1.69c-.16.1-.34.16-.51.16z"/>
                        <a href="{{url}}" class="article-list-link">{{title}}</a>
                        {{#if internal}}
                          <svg xmlns="" width="16" height="16" focusable="false" viewBox="0 0 16 16" class="icon-lock" title="{{t 'internal'}}">
                            <rect width="12" height="9" x="2" y="7" fill="currentColor" rx="1" ry="1"/>
                            <path fill="none" stroke="currentColor" d="M4.5 7.5V4a3.5 3.5 0 017 0v3.5"/>

    What I want is to add {{body}} underneath <a href="{{url}}" class="article-list-link">{{title}}</a> but I can only print the full article's body, which obviously breaks the whole layout. 

    I tried many things like {{body.slice 0 50}} and more, but nothing seems to work. 

    For the records: I am a developer, I have been through Zendesk documentation (Plus forums, stack overflow, your support, etc) and nothing seems to work. 
    Can you give me a hand to achieve this? 


  • Tomas M. Parra

    By the way, your console says either something like "body.slice cannot be accessed" , or something like "body doesn't accept these parameters". 

  • Ryan Gilomen

    Tomas M. Parra,

    I use {{excerpt body characters=150}} on my section pages to achieve this.

    Hope this helps!


  • Tomas M. Parra

    Hello @Ryan!
    That worked great for me. Thanks so much!

  • Casey Keefe

    Hey Zendesk & Community! I am trying to use on home_page.hbs to change content based on selected language.

    I have been able to use this in both header.hbs and footer.hbs with no problems, but getting the following error when I try to use it on home_page.hbs

    I am trying to avoid using the Dynamic Content feature if at all possible (just haven't had good luck with it). Thanks!

  • Cory Waddingham

    Is there a way to add metadata for a page? For example, on article pages, I want to add a <title> tag to the page header, so that page crawlers will know the title of the article without any trouble. But I can't find a way to add that page tag, either in the article_page.hbs or the document_head.hbs (adding 

    {{#if article.title}}

    just results in an error.

  • Tipene Hughes
    Zendesk Developer Advocacy

    Hey, Casey Keefe!

    You can access the help_center object in the home_page.hbs file. The object has the locale property available which should be what you're looking for.

    Feel free to reach out with any questions!


  • Tipene Hughes
    Zendesk Developer Advocacy

    Hi Cory Waddingham,

    The article object is not accessible within the document_head.hbs file. One way you could look at going about this is by using a bit of custom Javascript to append a title to the page. Here’s an example of one way that could work:

    // Create title element 
    const title = document.createElement('title');
    // Get article title element
    const articleTitle = document.querySelector('.article-title');

    // If article title exists, add title to document head
    if(articleTitle) {
      title.innerText = articleTitle.innerText;


I’m not super familiar with how crawlers interact with dynamically added meta data though so that might be something to look in to if you haven’t already.

    Let me know if you have any questions!


  • Casey Keefe

    Thank you Tipene Hughes !


Please sign in to leave a comment.

Powered by Zendesk