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.

1 Like