# Custom Homepage for Groups

**URL:** https://meta.discourse.org/t/custom-homepage-for-groups/199623
**Category:** Theme component
**Created:** [August 7, 2021, 8:12pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623 "2021-08-07T20:12:05Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 7, 2021, 8:12pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/1 "2021-08-07T20:12:05Z")

</div>

## Overview

When installed and added to the active theme, this theme component enables you to control the ‘homepage’, allowing it to be different from the set of pages Discourse allows by default, as well as having different groups have different “homepages” (e.g., group members care only or mostly about a particular category). This can be for all users, anon (non-logged in), mobile users, or according to a user’s **primary group**. Initially developed by @pfaffman. See [User-specific Discourse home page](https://meta.discourse.org/t/user-specific-discourse-home-page/160229).

### Use-cases:

1. You want something other than the ‘normal’ homepage
2. You want a different homepage for Anonymous users
3. You want a different homepage for Mobile users
4. You have a group of folk only interested in using a small slice of your instance. They want to only see their specific category.
5. Temporarily redirect a group of your punters to a special event or the like.
6. Have different landing pages for different groups.

## Settings

### custom default homepage

Allows you to set a global custom homepage.

### anon page

This enables you to use a specified page for those who aren’t logged into your site. Over-rides the global one above.

### mobile homepage

As per [Force Mobile Homepage](https://meta.discourse.org/t/force-mobile-homepage/95705) this allows you to set a different homepage for mobile users. This will override the options chosen above.

### group page map

This allows for multiple entries. Each entry should be of the format `group_name:path` , where `group_name` is the group slug (not the group `Full Name` ) and the `path` is the desired home page (e.g., “/c/great-category/4”).

> ![image](https://global.discourse-cdn.com/meta/original/3X/4/9/49213a7a53b1be5a9d06dd59926e528dc6865e47.png)

Ensure that the target users have the specified group denoted as their **primary group** and you are away. If the theme setting or the user primary group is changed, a reload will be required to have the change take effect.

> ⚠ The users with a specified group as **primary** will not be able to reach your ‘normal’ homepage unless you ensure that there is a way for them to do that (such as the native sidebar functionality)

## Known Issue - limited to relative URLs

And that doesn’t include [Page Publishing](https://meta.discourse.org/t/page-publishing/151971), unfortunately. However, you can workaround this by creating a permalink that will redirect to the external site and point to that permalink.

- @pfaffman tested this with a permalink at `/go-google` that redirects to `https://google.com` and something like `group-name:/go-google`
- you create Permalinks via the admin settings `/admin/customize/permalinks`

| | | |
| --- | --- | --- |
| 🛠 | **Repository** | [GitHub - pfaffman/discourse-custom-homepage-for-groups: Discourse theme component to change home page based on user's primary group · GitHub](http://github.com/pfaffman/discourse-custom-homepage-for-groups) |
| ❓ | **Install Guide** | [How to install a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682) |
| 📖 | **New to Discourse Themes?** | [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) |

---

<div class="post-metadata">

### Author: ![Zup](https://avatars.discourse-cdn.com/v4/letter/z/c37758/32.png) [@Zup](https://meta.discourse.org/u/Zup)
#### Post date: [November 28, 2021, 12:28am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/2 "2021-11-28T00:28:05Z")

</div>

This is a ~~game~~ _group_ changer! 🤪

Good job! Rather powerful TC…

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [November 28, 2021, 12:33am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/3 "2021-11-28T00:33:33Z")

</div>

We’ve got a few tweaks at the PR stage, addressing these:

> [@nathank](#):
>
> 1. Improve explanations within the component
> 2. Specific setting for an anon path

And also adding control of the mobile homepage if you wish it to be different (as per [Force Mobile Homepage](https://meta.discourse.org/t/force-mobile-homepage/95705)).

This increases its power significantly, so hope you like it.

---

<div class="post-metadata">

### Author: ![lisandro\_iaffar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lisandro_iaffar/32/315816_2.png) [@lisandro\_iaffar](https://meta.discourse.org/u/lisandro_iaffar)
#### Post date: [December 11, 2021, 8:54am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/4 "2021-12-11T08:54:16Z")

</div>

Hello!! This is awesome!! 🙂  
Thank you very much, this is actually important for my my case (use-case 1).  
I have to ask, about " The users with a specified group as **primary** will not be able to reach your ‘normal’ homepage", what do you mean by “actively provide a way for them to do that” ?  
Also, in line with this concept, it will also be useful to show in the homepage a specific order of the categories depending on which group the user belongs to. For example, to show their category at the top, and all the rest below of that. Do you think this is possible? (if not already?).

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 11, 2021, 10:09am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/5 "2021-12-11T10:09:50Z")

</div>

> [@lisandro\_iaffar](#):
>
> The users with a specified group as **primary** will not be able to reach your ‘normal’ homepage", what do you mean by “actively provide a way for them to do that” ?

It means that whatever home page you set in the site settings will be overridden. So if you want users to be able to get there then you’ll need to see that there is a link to get there… Somehow.

> [@lisandro\_iaffar](#):
>
> it will also be useful to show in the homepage a specific order of the categories depending on which group the user belongs to. For example, to show their category at the top, and all the rest below of that.

I can’t imagine how that would work (maybe I have a bad imagination 🤷‍♂️). The use case that I can think of makes users have a different category set as home if the are in a group. Like a car site could let you choose the Ford group as your home page.

If you want different stuff available for different groups then I think you’d do that by having default muted categories.

---

<div class="post-metadata">

### Author: ![lisandro\_iaffar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lisandro_iaffar/32/315816_2.png) [@lisandro\_iaffar](https://meta.discourse.org/u/lisandro_iaffar)
#### Post date: [December 11, 2021, 3:24pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/6 "2021-12-11T15:24:46Z")

</div>

Hi Jay!  
Thank you for your answer 🙂  
Lets say I would like to have different categories “pinned” at the top depending to which group a user belongs to. I mean, each different user would see a different “pinned” category. I don’t want to hide the other categories from the user, just make easily visible and readily available the one they will be using the most, right from the homepage (if possible!).  
(of course, I’m not “demanding” anything here, just asking if it’s possible with available settings/components)

---

<div class="post-metadata">

### Author: ![jrgong](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@jrgong](https://meta.discourse.org/u/jrgong)
#### Post date: [December 11, 2021, 6:43pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/7 "2021-12-11T18:43:49Z")

</div>

Hey @lisandro_iaffar

I had a the exact use case which I posted here: [Showcased Categories - #18 by jrgong](https://meta.discourse.org/t/showcased-categories-theme-component/173524/18)

In my case I set up my advertiser’s client category as homepage with this TC, but they just found it confusing and asked me to remove it again. Hence I think the showcased categories tc with such a modification would be the perfect solution.

---

<div class="post-metadata">

### Author: ![lisandro\_iaffar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lisandro_iaffar/32/315816_2.png) [@lisandro\_iaffar](https://meta.discourse.org/u/lisandro_iaffar)
#### Post date: [December 13, 2021, 4:56am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/8 "2021-12-13T04:56:02Z")

</div>

Hi @jrgong! 🙂  
Thank you very much for pointing me to that topic! And yes! That would be just perfect! I’m moving there to support the idea 💪  
Thank you again!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 9, 2022, 6:15pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/9 "2022-09-09T18:15:42Z")

</div>

I just submitted an update that deals with the ~~new~~ preLoadStore, which was causing it to have the wrong topics displayed on first load.

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [September 25, 2022, 9:08am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/10 "2022-09-25T09:08:30Z")

</div>

Hey Jay, I’ve noticed an error after my last Discourse update:

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/4/1/1410d57ff60671891cd3e281e9605a637637b941.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 26, 2022, 2:55pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/11 "2022-09-26T14:55:00Z")

</div>

Are you sure that’s the most recent version in github? (Not your fork or a static/local version?) I just ran an upgrade and it’s working. Also looking at the code, there’s only one place where `api` is used:

```
        const user = api.getCurrentUser();

```

and that’s inside a block that definces `api`.

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [September 26, 2022, 8:19pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/12 "2022-09-26T20:19:45Z")

</div>

That is odd. I’ve removed it from that instance anyway as it was surplus. And it seems to be working fine after updating in another instance. Weird. Thanks for taking a look!

Any idea how it interacts with the sidebar? I need to give it a whirl as it looks like the issue of needing a route back to the forum home has been solved by it.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 26, 2022, 8:27pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/13 "2022-09-26T20:27:53Z")

</div>

> [@nathankershaw](#):
>
> Any idea how it interacts with the sidebar?

I’ve not tested, but I can’t imagine why not. Please note, I may not have a very good imagination.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [November 3, 2022, 8:24am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/14 "2022-11-03T08:24:04Z")

</div>

I’m testing this now, but have two comments:

1. The anon path is not working for us - does it require the same format as the group map?
2. It would be great if there’s a default setting that would just apply to _everyone_.

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/f/c/cfc51fcd82122f4079afbb5dca1e969dece1f844.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 3, 2022, 10:53am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/15 "2022-11-03T10:53:49Z")

</div>

> [@bartv](#):
>
> The anon path is not working for us

Hmm. I thought I’d tested it on the list commit.

> [@bartv](#):
>
> It would be great if there’s a default setting that would just apply to _everyone_

Indeed. I guys the people who needed it didn’t need to change to a non-supported home page.

I’ll try to have a look tomorrow though it may be next week.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 3, 2022, 11:17am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/16 "2022-11-03T11:17:46Z")

</div>

> [@pfaffman](#):
>
> Hmm. I thought I’d tested it on the list commit.

FWIW It worked for me when I was playing with it yesterday (I had `tag/featured/` in there)

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [November 3, 2022, 11:33am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/17 "2022-11-03T11:33:54Z")

</div>

> [@bartv](#):
>
> The anon path is not working for us - does it require the same format as the group map?

It is working fine for me. It only needs the relative path.

But I had the same problem as you until I actually added the component to the Theme! Have you done that?

> [@bartv](#):
>
> It would be great if there’s a default setting that would just apply to _everyone_.

Yeah, I did think that needed adding. Here 'tis:

[https://github.com/pfaffman/discourse-custom-homepage-for-groups/pull/4](https://github.com/pfaffman/discourse-custom-homepage-for-groups/pull/4)

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [November 3, 2022, 11:42am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/18 "2022-11-03T11:42:05Z")

</div>

> [@nathankershaw](#):
>
> But I had the same problem as you until I actually added the component to the Theme! Have you done that?

~~Yeah, the same theme works fine when logged in, just not for anon. And just to be sure: the relative URL needs to start with a /? Asking because Jammy used `tag/featured/` while I use `/c/artwork/8`.~~

I got this to work - it was a mistake on my end.

> [@nathankershaw](#):
>
> Yeah, I did think that needed adding. Here 'tis:

Perfect, thanks! It’s not showing for me as an update yet though - should it?

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [November 3, 2022, 11:47am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/19 "2022-11-03T11:47:53Z")

</div>

> [@bartv](#):
>
> Perfect, thanks! It’s not showing for me as an update yet though - should it?

It is in my fork. You can install that directly yourself from here if you like until Jay merges it:

[https://github.com/nathan-nz/discourse-custom-homepage](https://github.com/nathan-nz/discourse-custom-homepage)

> [@bartv](#):
>
> the relative URL needs to start with a /

Works with or without a `/`

### BTW

The way you have it configured won’t work as users can’t have any of the trust\_level groups as their primary group.

> [@bartv](#):
>
> Yeah, the same theme works fine when logged in, just not for anon.

Thinking about that - is it added to the default theme for the site (anon uses this)? I’ve been tripped up by adding a component to my ‘dev’ theme but not the default theme.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [November 3, 2022, 11:59am UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/20 "2022-11-03T11:59:19Z")

</div>

> [@nathankershaw](#):
>
> Thinking about that - is it added to the default theme for the site (anon uses this)? I’ve been tripped up by adding a component to my ‘dev’ theme but not the default theme.

Yeah I found the mistake - it was related to that 🤦‍♂️

[Next page](https://meta.discourse.org/t/custom-homepage-for-groups/199623.md?page=2)
