Discourse Category Home 🏠

AI-generated summary

The plugin Discourse Category Home by merefield allows users to have personalized homepages based on their Primary Group, redirecting them to a specific Category upon visiting the community homepage. Setup involves creating Categories and corresponding Groups, assigning users to those Groups, setting them as Primary Groups, and granting Category permissions — all using Discourse’s native features. The plugin is lightweight, maintainable, and supports styling via category banners. It relies on the logic: CategoryGroup.where(group_id: primary_group).first.category_id, so each Primary Group should be permissioned to only one Category. merefield encourages GitHub stars and is open to elegant configuration suggestions. For users unable to install plugins, a Theme Component alternative is suggested. One user, Drew-ART, initially encountered a build error due to a syntax issue in app.yml, but after correction and a rebuild (possibly aided by Discourse Doctor), the plugin worked successfully Drew-ART. merefield confirmed the plugin builds fine and noted a recent locale fix unrelated to the error.

Summary:

Give users each a specific Homepage (“Home Category”) in your community.

It allows you to have a single Discourse in which users have specific “home pages” (read: Category) as determined by their Primary Group.

:link: GitHub: Repository https://github.com/merefield/discourse-category-home
:arrow_right: Install: Follow the plugin installation guide.

Enjoying this plugin? Please :star: it on GitHub ! :pray:

Features

Using only the available interface elements of a normal Discourse, makes this a robust, easy-to-maintain solution.

Configuration

Using normal Discourse functionality:

You are DONE! :tada:

Now whenever someone navigates to your community Homepage, they will be redirected to the Category for which their Primary Group is permissioned.

NB: This follows a simple rule you must stick to: If someone has a Primary Group registered and that is permissioned to a single Category, it will redirect to that Category as their home.

Using a Primary Group in this way has a number of advantages, as you may have noticed from the link above, not least:

  • You can give someone a Title
  • You can give them a Flair
  • You can style their Posts

Other considerations

Make your Category Homepages more impactful by styling them distinctly, with e.g.: Category Banners

Checking distinct Category/Primary Group Permissions

To check your Primary Group is only associated with a single Category, you can use this handy out-of-the-box feature of Discourse, e.g.:

There is but one Category in the list, good! :+1:

The Technical Bit

The exact logic employed is this:

   return CategoryGroup.where(group_id: primary_group).first.category_id

Whilst it might be possible to ‘fudge’ it, it is probably unwise if you use that Primary Group on more than one Category if you expect this to work, so bear that in mind and keep to my recommendation.

Providing more flexibility

I’m open to suggestions on how else to configure this behaviour but I’d like to limit the amount of bespoke settings and use as much out of the box behaviour and data as possible. If you have a simple, elegant solution in mind let me know.

Can’t install plugins/Primary Group thing doesn’t work for you?

If you can’t install Plugins (because you are on a restrictive hosting plan), or find the Primary Group configuration doesn’t work for you, consider this Theme Component alternative: Custom Homepage for Groups which requires more bespoke configuration, but is less invasive.

24 Likes

I get an error message when trying to rebuild after adding this to my app.yml file

Pups::ExecError: cd /var/www/discourse/plugins && git clone GitHub - merefield/discourse-category-home: Alters the user's homepage to become the Category of their Primary Group ¡ GitHub failed with return #<Process::Status: pid 391 exit 128>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn’

Is it still working for others?

Seems to be building fine. Check your app.yml clone syntax.

I deployed a fix for a missing locale string though :slight_smile: (but that won’t have caused your issue).

1 Like

Yes working great now, thanks for the excellent plugin. Discourse Doctor fixed it, must’ve been a problem in the build last time i rebuilt the app.

1 Like