Knowledge Base Plugin

Personally, I’d like to see it appear in the hamburger menu… it could be enabled via an admin setting, similar to the events plugin.

The link in hamburger menu could match the knowledge base title


I installed this plugin to test it. I could see the option to reorder topics in a category, but not the categories themselves (seems like the meaning of category is different to the discourse one). Can we get similar sorting for the top level assigned discourse categories?

That’s the only thing thats missing for me to use it at this point :slight_smile:

i.e. where it says “save” and “cancel”, can we have sorting options there aswell, so that we can organise multiple knowledge base categories?



You can vote for said feature here - one more vote and it gets added to the workflow!


Yes. See site setting “fixed category positions” If checked, you will be able to arrange categories into a fixed order. If unchecked, categories are listed in order of activity.


I think that setting fixes the ordering for the discourse but doesn’t have any relation to the ordering on the kb. It’s been a while since I tested but I think the order for this plugin atm is fixed based on the order you give a category the “be a kb category” setting so reordering is super tedious.


That could be true.

Again, I don’t know much about the Knowledge Base plugin (mostly from watching this topic, not using it), but if you have more than a few categories, reordering them is indeed tedious. Somewhere here is a topic where I describe how to sort them at the rails console, which helps only if you want them in alpha order.


More awesome work, thank you @angus!

I’ve got a flow issue with a kb page linking to a second kb’s page when the original topic url is used.

For example, given the following 2 pages:


If I link to #2 from within #1 using the kb-url, the mini-onebox doesn’t render. Also, when viewing #1’s original (non-kb) topic, the link to the kb-url kicks me into the kb unexpectedly, which is jarring.

However, if were to use the original topic url instead, the mini-onebox does render but now links within the kb kick me out back into the normal topic view.

What I’m hoping is possible is that the topic view links to topic view (like normal) but the kb page knows to link to the kb version. That way the flow is preserved no matter where you are reading the interlinking content.

Is that even viable enough for a feature request, or is that too crazy?


Sounds viable! I think I get what you mean but I’ll test it out on my instance to double check in a bit. Do you have a live site with an example of the behavior?

You can fill out a feature request for this here. :slight_smile:

1 Like

I currently do this often with SQL.

UPDATE categories
SET POSITION = subquery.position
	, CASE WHEN category_id = 0 THEN parent_category_id ELSE category_id END category_id 
	, CASE WHEN category_id = 0 THEN parent_category_name ELSE category_name END category_name 
		, parent_category_id
		, parent_category_name
		, category_id
		, category_name
		FROM ( SELECT row_number() OVER ( ORDER BY parent_category_name, category_name )
		, * FROM (
			SELECT id parent_category_id
			, name parent_category_name 
			, 0 category_id
			, cast('' AS text) category_name
			FROM categories 
			WHERE parent_category_id IS NULL ORDER BY name
		) parent_categories
			SELECT child.parent_category_id
			, parent_category_name 
			, category_id
			, category_name
			FROM categories child
			INNER JOIN categories parent
			ON child.parent_category_id =
			WHERE child.parent_category_id IS NOT NULL ORDER BY
		) parents_with_children
		ORDER BY parent_category_name, category_name
		) ordered_parents_with_children
	) category_positions_sorted_alphabetically
) subquery
WHERE id = subquery.category_id ;

I run the code by starting up a psql session.

/var/discourse/launcher enter app
su postgres
psql discourse

and then executing the SQL.

Sure! Yeah I hard time wording what I meant. I added examples below:

The first “Imperial Conflict” link looks right, but takes you away from the kb. The second link doesn’t render the mini-onebox but does keep you in the kb.

Compare to this to the topic version:

Here, the first link looks right and preserves the flow between topic views. However, the second link now breaks you into the kb from a topic, which feels strange.

Ideally, the same topic url could be used in either view, and the topic version would link to a topic like it does now, and a kb page would link to a kb page.

I added it as a feature request w the same examples here.

1 Like

Is it possible to have some hierarcy in the topics?

So the left side could be a foldable tree?

What is the concept of searching through the kb?

1 Like

a simple question which I’m sure you already investigated:

isn’t it possible to have such functionality as a theme? what features do make it different from a theme?

Thanks for submitting @FoohonPie!

At present it only supports categories with topics where you can expand and maximize each category.

The closest thing to kb-specific search is to use the in built discourse search and set it to only search within the kb-specific categories.

At a minimum don’t think you can create category settings and add the route with a theme. In general things are just more robust with a plugin. There’s a lot going on in the plugin.rb file (discourse-knowledge-base/knowledge_base_controller.rb at master · angusmcleod/discourse-knowledge-base · GitHub).

In terms of convenience the Procourse Installer makes it super easy to install/uninstall plugins without having to rebuild through the server.


Hello -

We installed the Knowledge Base Plugin and wanted some help. We’d like to use the KB as the single source of truth for all of our learning content (guides, tutorials, modules).

Is there a way to create a topic that is featured in the KB but does NOT show up in a category or latest topics? If so, can my KB content still be searchable inside Discourse?

1 Like

Hi Angus,

Will topics created by non-admin users will be added to the KB? I want to use the KB to upload curated content from many categories, but would like to make sure that topic generated by non-admins will not be added to KB. Please confirm — thanks in advance!

1 Like

perhaps a bug:

if one choose a category as a knowledge base, and then he removes it from being knowledge base, both by selecting/de-selecting the option in category setting, the category is not removed from knowledge base!

@Pad_Pors Yes, I think I’ve seen the same bug. Could you submit it here? Thanks

1 Like

I’ve been dealing with the same bug, I’ve also sent a bug-report.

Also, maybe I’m being a bit of an idiot (I’ve been known to do that at times), but if I nominate a category and a sub-category within it to be knowledge bases, the subcategory’s base topics are duplicated within the category’s base. I understand that behaviour within a forum, but is there a way to cull the duplicates within the knowledge base? Especially as the duplicated topic leads to an error instead of the post in question when clicked.

1 Like

@Pad_Pors @undeadcorvid Thanks for the reports. The issue is fixed:


Thanks for the swift update, much appreciated :slight_smile: