Search suggestions

Display a curated list of search keyword suggestions to users in order to help them find helpful content.

Suggestions as badges
View code
<template id="tmpl-popular-keywords">
  <div class="flex flex-first flex-wrap mt-5 mb-4 justify-content-center"
   x-data="Widgets.popularKeywords"
   x-init="parseKeywords('<%= keywords %>')">
    
     <p class="font-semibold m-1">
        
          
        
          
        
      </p>
    
    <div class="flex flex-wrap align-items-center">
      <template x-for="(keyword, index) in keywords" :key="index">
        <div class="flex align-items-center m-1">
          <a class="inline-block text-inherit badge bg-translucent blur text-inherit rounded px-3 py-2 hover:text-inherit"
            :href="keyword.html_url"
            :title="keyword.title"
            x-text="keyword.title">
          </a><span x-show="index !== keywords.length - 1">,</span>
        </div>
      </template>
    </div>
  </div>
</template>
Suggestions as badges
View code
<template id="tmpl-popular-keywords">
  <div class="flex flex-first flex-wrap mt-5 mb-4 justify-content-center"
   x-data="Widgets.popularKeywords"
   x-init="parseKeywords('<%= keywords %>')">
    
     <p class="font-semibold m-1">
        
          
        
          
        
      </p>
    
    <div class="flex flex-wrap align-items-center">
      <template x-for="(keyword, index) in keywords" :key="index">
        <div class="flex align-items-center m-1">
          <a class="inline-block text-inherit badge bg-translucent blur text-inherit rounded px-3 py-2 hover:text-inherit"
            :href="keyword.html_url"
            :title="keyword.title"
            x-text="keyword.title">
          </a><span x-show="index !== keywords.length - 1">,</span>
        </div>
      </template>
    </div>
  </div>
</template>

Search suggestions are designed for use with the search bar on the Home page, but can be used anywhere in the help center.

Search suggestions can be added to the Home page (home_page.hbs) using the Popular keywords theme setting in the Home page elements setting group.

  1. Select a style from the Popular keywords style dropdown list.
  2. Enter one or more keywords in a comma-separated list.

The search suggestions will then appear below the search bar in the hero element in the style selected.

To use a custom pattern, copy the <template> from your selected pattern into the bottom of the Footer (footer.hbs) template.

Search suggestions can be added to any page by copying-and-pasting the following hook into a page template:

{{~#isnt settings.popular_keywords_style 'none'}}
  {{~#if settings.popular_keywords}}
    <div id="popular-keywords">
      <script type="text/javascript">
        ready(function() {
          Util.renderTemplate(document.getElementById('popular-keywords'), 'popular-keywords', {
            keywords: '{{#if settings.use_translations}}{{dc settings.popular_keywords}}{{else}}{{settings.popular_keywords}}{{/if}}'
          });
        })
      </script>
    </div>
  {{/if~}}
{{/isnt~}}}

The search suggestions will appear in the position of the hook element on the page.

To use a custom pattern, copy the <template> from your selected pattern into the bottom of the Footer (footer.hbs) template.

If you select the Custom template style option, copy-and-paste your selected pattern template into the bottom of the Home page (home_page.hbs) or Footer (footer.hbs) templates.

Related patterns