US English (US)
BS Bosnian

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.

  • Book a Demo
  • Product Updates
  • Contact Us
English (US)
US English (US)
BS Bosnian
  • Home
  • Customization
  • Customization Guides
  • Advanced Customization

Loops Examples

Written by Jose Souza

Updated at May 20th, 2020, by Jose Souza

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.

  • Getting Started
    Users Accessibility New to Helpjuice? Start Here Content Management Multiple Languages/Translations & Localization Multilingual Knowledge Bases Analytics Video Tutorials
  • Customization
    Customization Guides
  • API V2
  • API V3 and Webhooks
  • Article Editor
  • Billing / Subscription
  • Authentication
  • Pricing
  • Swifty AI Chatbot
  • Swifty AI Helpbar
  • What's New
+ More

Need a little help with our code? this code-snippets might be it.

Simple loop through categories:

Used mostly on the index page

{% for category in roots_categories %}
    <a ... href="{{category.url}}">
      <span>{{category.name}}</span>
    </a>
{% endfor %}

Looping through subcategories:

also listing the questions

 {% for subcategory in subcategories %}
            ...
         <a href="{{ subcategory.url }}">{{ subcategory.name }}</a>
            ...
        <ul ...>
              {% for question in subcategory.published_questions | limit:5 %}
                <li>
                      <a href="{{ question.url }}">{{ question.name }}</a>
                </li>
              {% endfor %}
        </ul>

    {% if subcategory.questions.size > 5 %}
      <a href="{{subcategory.show_all_questions_link}}" ... >See all {{subcategory.questions.size}} topics</a>
    {% endif %}
  {% endfor %}

Adding personalized Category/Subcategory text

Inside the category loop just test with a if condition to make it appear a subtext related to the category

{% for subcategory in subcategories %}
            ...
         <a href="{{ subcategory.url }}">{{ subcategory.name }}</a>
{% if subcategory.name == 'Customization'%}
<p>Subtext related to the category</p>
{%else%}
<p>Subtext related to the category</p>
{%endif%}

        <ul ...>

Just a parenthesis here the else condition is not required, and you can also use other conditions to cover the realm of possibilities using

{%elsif  subcategory.name == 'Customization'%}

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • How Can I Contextualize The Template?
  • Using Custom Inputs On Your Contact Form
  • Integrating Your Knowledge Base With Your Ticketing System
  • Displaying The Most Popular Questions
  • How To Show Different Number Of Questions On Homepage

Copyright © 2025 - Helpjuice

Helpjuice, Inc. is a registered US Corporation, EIN # 45-2275731

Download W9
  • Help
  • Features
  • Pricing
  • About
  • Careers
  • Customers
  • Blog
  • Case Studies
  • Resources
  • Knowledge Base Examples
  • Privacy Policy
  • Terms of Service

Why is the knowledge base important?

With a knowledge base, you can allow your customers to self-help themselves, thus reducing your customer support by up to 60%. Furthermore, you can also have your team get instant answers to the questions they need without having to email themselves all using knowledge base software.

What is the purpose of a knowledge base?

The purpose of knowledge base software is to allow you to host your knowledge base/corporate wiki in one centralized 'hub'. Both your customers, and employees can now access information within seconds!

Made with from Miami, Bosnia, Morocco & Brasil

+1 (833) 387 3877 support@helpjuice.com
Expand