Skip to main content
Support

Getting Started with a Custom HTML Template

Customize HelpDocs with custom HTML templates using Handlebars: enable them in Settings > Customize, edit partials like header, footer and article, or start from starter templates.

Taylor
Updated by Taylor
6 min read

Table of Contents

HelpDocs ships with a bunch of nice looking templates that work great out of the box. You can customize our default templates easily with CSS and JavaScript to make them look however you like.

If you want to make large changes to the layout, that's where custom HTML templates come in.

This feature is available on certain plans.

Handlebars

We use Handlebars to give our HTML templates superpowers. Handlebars lets you do things like loop through arrays of tags and authors, and output HTML for each. It also lets you register and reuse partials which cleans up your HTML no end.

If you're not familiar with Handlebars you should check out the official documentation.

HelpDocs templates are compatible with all the syntax of Handlebars v3, with the addition of Inline Partials from Handlebars v4. Other v4 additions, like partial blocks, aren't supported.

We also support a number of helpers for Handlebars. We've built these helpers in-house to make common tasks like internationalization easier. You can read more about our helpers here.

Enabling Custom HTML Templates

  1. Head to Settings > Customize
  2. In the Design panel, find the Brand section
    Customize help center menu showing the Design tab with Brand and Navigation options.
  3. Choose Custom from the Template dropdown
    Template dropdown set to Custom with a note directing users to edit HTML in the HTML panel
  4. Either use our a Starter template (based on one of our stock templates) or create your own from scratch:
    1. Using a Starter template. If you select this, you'll get a choice of which template to use as a starting point and which partials it'll override. Just click Start from a template in the callout
      Notice explaining settings ignored by custom templates, with a Start from a template button.
    2. Start from scratch. If you want to create it yourself, head to the HTML tab straight away. This is where you'll manage the HTML and Handlebars for each partial of your Knowledge Base
A custom template ignores your Logo, Dark mode logo, Navigation, and Primary Color unless its HTML uses them. Template Options don't apply either.

Partials

Since you only have to provide the content for each page, not the whole HTML (include <head> tags, <link>s, etc.), we call each section you can edit a partial. There's 7 total partials, 6 of which you can edit. Here's a breakdown of what you'll find by heading to Settings > Customize > HTML.

Partial Name

Purpose

default.hbs

This is the default template that includes the main layout of the HTML. It's maintained by us here at HelpDocs and isn't user editable. This is where we insert metadata for SEO, our required JavaScript libraries, add your integrations, etc.

header.hbs

You should add your header bar and navigation in here. This appears on every page of your Knowledge Base. Depending on how you wanna structure your template, this might also be the right place for your search bar and maybe some secondary navigation like a sidebar. If you need to register inline partials for use in all templates, here's a good place to do that too.

footer.hbs

This gets added after your main content (e.g. after the category or article that's being displayed). You can use this to mirror the footer on your main website, or add any scripts to your site that you want before the closing </body> tag.

home.hbs

The entry point of your Knowledge Base. This is where you display all your categories, so users can easily navigate to a category or article.

category.hbs

Display a single category and all its articles.

article.hbs

Display a single article.

search.hbs

Display search results. Custom templates ship with instant search as standard, but this page is shown when someone hits return in the search bar regardless.

Context Data by Partial

We pass through context data you can use in the templates. This differs slightly on each partial so you only have the information that's actually relevant to that page. Data can be accessed using Handlebars data accessors, e.g. {{categories}}

Data

Example

Available in Partial(s)

categories

[Category]

home.hbs, category.hbs, article.hbs, search.hbs

category

{
  category_id: String,  parent_category_id: String,  slug: String,
  title: String,
  description: String,  url: String,
  relative_url: String,
  icon: String,
  is_featured: Boolean,
  articles: [Article],
  authors: [Author]
  meta: {
    num_authors: Number,
    num_articles: Number,
  }
}

category.hbs, article.hbs

article

{
  article_id: String,  category_id: String,
  author: {
    user_id: String,
    profile_image: String,
    name: String,
  },
  slug: String,
  title: String,
  description: String,
  url: String,
  relative_url: String,
  icon: String,
  body: String, // only available in article.hbs. It's HTML, so output it with triple braces
  toc: String, // only available in article.hbs. Also HTML
  prev: Article, // only available in article.hbs
  next: Article, // only available in article.hbs
  is_published: Boolean,
  is_private: Boolean,
  is_featured: Boolean,
  show_toc: Boolean,
  created_at: Date,
  updated_at: Date,
  tags: [String],
  
  category_title: String, // only available in search.hbs
  category_titles: [String], // only available in search.hbs
  text_fragment: String, // only available in search.hbs
  title_highlight: String, // only available in search.hbs
  description_highlight: String, // only available in search.hbs
}

The full article object is available in article.hbs. In other partials, some fields (notably body) may be missing.

articles

[Article]

search.hbs

search_term

String

search.hbs. This is the term we searched for after normalizing it.

original_search_term

String

search.hbs. This is what the reader typed.

search_result_count

Number

search.hbs

meta

{  canonical: String,
  home_path: String,
  home_url: String,
  sidebar_categories: [Category],
  related_articles: [Article],
  top_articles: [Article],
  language_code: String,
  languages: [    {
      code: String,
      hreflang: String,
      name: String,
    },
    ...
  ],
  default_language_code: String,
  language_is_rtl: Boolean,
  account_id: String,
  is_home_page: Boolean,
}

meta is available on all partials, but some of its attributes may not be available on some partials. Notably top_articles is only available in home.hbs and related_articles is only available in article.hbs.

user

{  user_id: String,
  name: String,
  email: String,
  profile_image: String,
  permission_groups: [String],
}

All partials. If there's no logged in user this will be empty.

config

{
  brand: String,
  logo: String,
  logo_dark: String,
  favicon: String,
  favicon_dark: String,
  colors: {
    primary: String,
  },
  nav_items: [
    {
      title: String,
      href: String,
      target: String,
    },
    ...
  ],
  contact_email: String,
  seo_title: String,
  seo_description: String,
}

All partials. These are your settings from Settings > Customize > Design and elsewhere, ready to use in your HTML.

The header and footer partials inherit the context of the page that's currently being rendered. So if you're rendering an article page, the header and footer will have access to that context, etc.

Starter Templates

It's not always fun, desirable, or time-sensible (totally a phrase now 😹) to create a template totally from scratch. So you can start from one of our default layouts instead.

The quickest way is in the HTML panel:

  1. Hit Start from a template
    Warning banner explaining which settings a custom template ignores, with a button to start from a template.
  2. Choose a layout from the Template dropdown. It offers the Startup, Startup with Sidebar Navigation, Docs and Ask v6 starters. We'll tell you if this replaces anything you've already got
  3. Hit Start. We'll fill in your partials, CSS, and JavaScript
  4. Hit Publish when you're ready (you'll see Save instead if your plan doesn't include drafts)
Prefer to see the files first? Get in touch and we can send you a link to a .zip file, so you can just just unzip, and follow the instructions in README.md.

What did you think of this doc?

Previous Handlebars Helpers for Custom Templates