How to bring in Latest topics when using category boxes

Hi Guys,

Our HR team have decided to go with category boxes instead of a category list as below.

However, they also would like the latest topics to appear at the bottom of the categories as seen in revoluts community page

I am struggling to work out how this can be done, either as an existing setting or with CSS,

any ideas?

Best Regards



Try to work with components

You can use: categories-and-latest-topics

In this mode, there is a connection and categories and recent topics.

<script type='text/x-handlebars' data-template-name='components/categories-and-latest-topics'>

<div class='column categories'>
  {{categories-only categories=categories}}

<div class='column'>
  {{categories-topic-list topics=topics filter="latest" class="latest-topic-list"}}


Next, you override: categories-only

<script type='text/x-handlebars' data-template-name='components/categories-only'>

   The contents of the file...


Perhaps from this file it is necessary to move the box with the categories, or to do simply to change the css.

Options think very many.

Useful material

1 Like

Another option is to simply structure your category directly


Then just change the css, which is even easier. )


Ideally I would prefer to do it like you have suggested, however, there isnt a way to display categories in a grid layout and have the latest topics below. :frowning_face:


I suggest building a static header customization if your categories do not change much. Then you could have whatever layout you like above the topic list.


I’ve built this or something similar for a few sites at this point. If you put this in the </head> section of your theme it will put all the categories on top of your home page (and /latest assuming that it’s the same as your homepage)

Then all you’ll need is add the CSS to structure this layout however you want. This is a good introduction to using the API and Handlebars templates in general.

<script type="text/discourse-plugin" version="0.8">
  const ajax = require('discourse/lib/ajax').ajax;

  api.registerConnectorClass('below-site-header', 'custom-homepage', {
    setupComponent(args, component) {
      component.set('hostname', window.location.hostname);
      api.onPageChange((url, title) => {
        if (url == "/" || url == "/latest"){ 
          $('html').addClass('show-custom-homepage'); // Show homepage
          component.set('displayCustomHomepage', true);
            ajax("/site.json").then (function(result){ // Get list of categories
              let categoryName = [];
            component.set('categoryName', categoryName);
        else { // Hide homepage
          component.set('displayCustomHomepage', false);

<script type='text/x-handlebars' data-template-name='/connectors/below-site-header/custom-homepage'>
  {{#if displayCustomHomepage}}
  <div class="custom-homepage-wrapper"> 

    <div class="wrap wrap-category-boxes">
      <div class="homepage-category-boxes">
        {{#each categoryName as |c|}}
        <a href="/c/{{c.slug}}" class="box">
          <div class="homepage-category-box">
            {{#if c.uploaded_logo}}
            <div class="category-image-wrapper">  
              <img class="homepage-category-image" src="{{c.uploaded_logo.url}}" />               
            <h2>{{#if c.read_restricted}}<i class="fa fa-lock">&nbsp;</i>{{/if}}{{}}</h2>


It looks very nice. How I can to add Font Awesome 5 instead of images? Many thanks!

1 Like


Thank you for this code snippet! I am working on a project where I need to do some things on this principle (not necessarily categories) and I would like to put this directly in the plugin that I develop.

I know where to put the template handlebars, but I can not find the folder / file where to put the javascript. Could you tell me how to proceed?

Thank you,

1 Like

I love this idea! Looking forward to test such a theme component or plugin

1 Like

Is there an update to this? I’m getting an error from the script not being able to get the category names. Nothing is changing on the page.

Yes, there was an error! Thanks for reporting it. I’ve fixed the code in the post above.

We turned strict mode on for our JavaScript, which means categoryName = []; needs to be declared, changing that line to let categoryName = []; was the fix.


This github link to hopefully the component that does this trick is 404.

1 Like

I think that component is now here:


Okay… I will need to figure out how to make an hbs work as something I can add to discourse. I guess I have to use this as a file in a component and I need to do a tutorial on that?
I saw one tutorial with a simple theme. Is that the right direction to go?

1 Like

I haven’t done this before, so I don’t know the answer. The theme developer tutorial would definitely be a good place to start.

If you search that page for “Mounting widgets”, you’ll see an example of displaying a widget in a different part of the page.

This #howto topic might also be useful as an example:


I’ll let you know if I’m successful. In the interim, I plugged in the Air theme and I’m quite happy, but I would still love to get latest posts below the category topics.

I was once an msvc++ programmer 25 years ago, and I did manage to build a playstore released flutter app. Open source api’s are not easy for me though. We will see how things go. I’ll post an update when I can.