# 如何替换/覆盖主页模板

**URL:** <https://meta.discourse.org/t/how-to-replace-override-homepage-template/381697>\
**Category:** Support\
**Created:** [2025年九月5日 10:06 UTC](https://meta.discourse.org/t/how-to-replace-override-homepage-template/381697 "2025-09-05T10:06:59Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)\
**Post date:** [2025年九月5日 11:23 UTC](https://meta.discourse.org/t/how-to-replace-override-homepage-template/381697/3 "2025-09-05T11:23:15Z")

</div>

Discourse 组件是用 JavaScript 编写的 😉

它为开发者提供了自定义主页支持，你可以区分这些用户类型。

> <https://github.com/discourse/discourse/pull/26291>
>
> This PR adds a theme modifier and route so that custom themes can opt to show th…eir own homepage. To use it, do the following: 
> 
> \### 1. Add a modifier to your theme (or component) for \`custom\_homepage\`
> \`\`\`json
> {
> "name": "Your theme name",
> "component": true,
> "modifiers": {
> "custom\_homepage": "true"
> }
> }
> \`\`\`
> \### 2. add a component in the \`custom-homepage\` connector. 
> 
> By default, when the modifier is added, admins will see an info alert as the homepage: 
> 
> \<img width="1419" alt="image" src="https://github.com/discourse/discourse/assets/368961/4102c4e8-0111-4bc5-af82-74d4440d0559"\>
> 
> 
> Themes or plugins can add elements to the \`custom-homepage\` plugin outlet. For example, a theme can add a file under \`javascripts/connectors/custom-homepage/home.hbs\` containing "Hey there!", and the homepage will display that component: 
> 
> \<img width="1348" alt="image" src="https://github.com/discourse/discourse/assets/368961/72e900f6-1361-4419-a49d-190395a5d4e5"\>
> 
> Note that this theme modifier respects the user's selected homepage (from Preferences \> Interface), if the user has picked a specific route as their homepage, that route will be shown to them.

---

_[View the full topic](https://meta.discourse.org/t/how-to-replace-override-homepage-template/381697)._
