# 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:** 1
**Showing post:** 84

<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: [June 1, 2025, 3:22pm UTC](https://meta.discourse.org/t/custom-homepage-for-groups/199623/84 "2025-06-01T15:22:33Z")

</div>

I’m still not sure why I deleted support for the default and anon homepages before. I put those back.

Now if there is a `custom_default_homepage` it uses that unless there is a matching group match. If there’s an `anon_page` and the user is anonymous, it uses that.

I couldn’t figure out how or when the mobile page should be set (is it for anon users? all users? does it override the default page? the group map?), so I deleted it. If you’re using that mobile page, tell me what you think it should override (I think maybe set it as the default page if they are on mobile, but if there is a group page, then use that? Still not clear what to do for anon vs logged in–I guess there maybe needs to be mobile versions for all of them?).

Here’s the code:

```javascript
      let url = null;

      if (settings.custom_default_homepage) {
        url = settings.custom_default_homepage.replace(/^\/+/g, "");
      }

      if (user) {
        if (user.primary_group_name && settings.group_page_map) {
          let groupMap = settings.group_page_map.replace(",", ":").split("|");
          const mapEntry = groupMap.find((value) =>
            RegExp(user.primary_group_name).test(value)
          );
          if (mapEntry) {
            url = mapEntry.split(":")[1].replace(/^\/+/g, "");
          }
        }
      } else if (settings.anon_page) {
        url = settings.anon_page.replace(/^\/+/g, "");
      }

```

And then it changes the homepage only if `url` has a value.

---

_[View the full topic](https://meta.discourse.org/t/custom-homepage-for-groups/199623)._
