Creating a custom filter homepage

AI-generated summary

In a discussion about creating a dynamic homepage in Discourse, MihirR sought to display multiple filtered topic lists (e.g., recent, most replied, most liked) without manually updating date filters daily. The current theme component allows date-based filtering (e.g., created-after:YYYY-MM-DD), but requires constant updates. awesomerobot suggested using the built-in /top list for weighted popularity and noted that duplicate topics across lists is a known limitation. They proposed enhancing the Filtered Topic Lists component with a “hide duplicates” feature, though this may reduce list size. manuel cautioned that multiple overlapping lists may feel static unless the community is very active, and recommended using a single list with manual time filters (e.g., Today, Weekly) via a block component. MihirR preferred multiple filters but later confirmed that awesomerobot’s recent Discourse update — allowing relative date filters like activity-after:7 or created-after:1 — solved the issue. MihirR confirmed the fix works perfectly and thanked awesomerobot for the quick resolution.

Can I create a dynamic homepage like this:

  • 10 Recently Active Topics (this week)
  • 5 Latest Created Topics (today)
  • 5 More Recent Topics (this week)
  • 5 Most Replied Topics (this week)
  • 5 Most Liked Topics (this week)
  • 5 Latest Created Topics (yesterday or today)

There’s a theme component through which I can create a homepage like this in Discourse Filtered Topics List, but I feel the drawback is that it only works with a certain timeframe, so I would have to change the timeframe daily.

I mean, for now, it works on a basis that I can add dates to it, like:

activity-before:YYYY-MM-DD topics with latest bump before specified date
activity-after:YYYY-MM-DD topics with latest bump after specified date
created-before: YYYY-MM-DD topics created before specified date
created-after:YYYY-MM-DD topics created after specified date

But then I would have to always change dates. Is there any alternative I can do in the forum?

Also, the major issue with this component is that it repeat topics in every sort

Does your case require these to be literally most replies/likes? If you use the /top topic list you can get automatic time periods… top factors in views, likes and post count (and you can adjust these weights a little bit with site settings)

Right this is a complication with sourcing multiple topic lists, a component would need to cross reference each list and remove duplicates. Not very complicated, but I don’t think this has been implemented in any available components.

Not entirely on replies and likes but yes, just trying to create a dynamic looking homepage.

So, a component which can remove the duplicate topic from either of the field will do the work?

Yeah it wouldn’t be too complicated to add a “hide duplicates” feature to Filtered Topic Lists, if @gormus is interested. The findFilteredTopics action could be modified to store every topic ID in a list, and then duplicates could be filtered out.

The downside is that if you want a list of 10 topics, you might only get 5 after duplicates are removed… but that could be partially avoided by maybe fetching a few extra beyond what was specified in the setting.

I’ve added filtered lists to homepages on several projects before and I’d caution that to populate multiple “most recent” lists with overlapping filters, you really need a very active community to begin with. Now when your community is that active, you’ll also have a much richer set of content to work with for building a dynamic homepage. In that case, a block of different lists might rather come off as static and not so visually appealing.

Though for a slightly different angle, you could also explore just putting one or two lists with a manual time filter. That could even feel more dynamic for the users. As in this view:

That’s a feature I took from the Central theme and it’s available here as a block component: Manuel Kostka / Discourse / Blocks / Top Topics · GitLab

True, this might work but however I actually wanted to populate multiple filters on the page.

Yes, that actually works. If @gormus would be interested :))

I’ve made an update today that will help with this a little bit: FEATURE: allow date-based filters to accept a day count by awesomerobot · Pull Request #33197 · discourse/discourse · GitHub (you should get this the next time you update Discourse)

This will allow you to enter your desired number of days into the activity/created-before/after filters, so you can do:

activity-after:7 topics active the last 7 days
created-after:1 topics created after 1 day ago

You can also use 0 for today (as in after midnight)

Damn, that was quick. Thank you!!

Hi @awesomerobot , just wanted to let you know I have made the required changes and it’s working perfectly fine now. Thank you :))