# 如何为所有用户设置相同的侧边栏分类

**URL:** <https://meta.discourse.org/t/how-to-set-the-same-sidebar-categories-for-all-the-users/402479>\
**Category:** Site Management\
**Tags:** sidebar\
**Created:** [2026年五月11日 07:59 UTC](https://meta.discourse.org/t/how-to-set-the-same-sidebar-categories-for-all-the-users/402479 "2026-05-11T07:59:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**Post date:** [2026年五月13日 15:38 UTC](https://meta.discourse.org/t/how-to-set-the-same-sidebar-categories-for-all-the-users/402479/5 "2026-05-13T15:38:17Z")

</div>

@Moin  
这里的回填（backfilling）工作方式与通常的预期略有不同。当更新“默认导航菜单类别”设置时，我们并不会简单地重置所有用户的侧边栏类别。我们的做法如下：

- 如果管理员在设置中添加了一些类别，那么只有这些新添加的类别会被加入到尚未设置这些类别的所有用户的侧边栏中。
- 如果从设置中移除了某些类别，那么这些类别也会从所有用户的侧边栏中移除。

因此，回填并不会强制将设置的状态应用到所有用户，而是仅对设置中新增或移除的类别进行增量更新。

这样做的主要原因是为了保留每个用户的个人偏好。

引入此行为的 PR 如下：

> <https://github.com/discourse/discourse/pull/18620>
>
> The previous sidebar default tags and categories implementation did not
> allow f…or a user to configure their sidebar to have no categories or
> tags. This commit changes how the defaults are applied. When a user is being created,
> we create the SidebarSectionLink records based on the \`default\_sidebar\_categories\` and
> \`default\_sidebar\_tags\` site settings. SidebarSectionLink records are
> only created for categories and tags which the user has visibility on at
> the point of user creation.
> 
> With this change, we're also adding the ability for admins to apply
> changes to the \`default\_sidebar\_categories\` and \`default\_sidebar\_tags\`
> site settings historically when changing their site setting. When a new
> category/tag has been added to the default, the new category/tag will be
> added to the sidebar for all users if the admin elects to apply the changes historically.
> Like wise when a tag/category is removed, the tag/category will be
> removed from the sidebar for all users if the admin elects to apply the
> changes historically.
> 
> Internal Ref: /t/73500

我们曾尝试通过以下两种方式使所有用户拥有相同的类别：

1. 全部添加，按历史应用；再移除部分，按历史应用。
2. 全部移除，按历史应用；再添加部分，按历史应用。

在最近一次针对大型站点的尝试中，方法 1 未能正常工作，而方法 2 则成功了。因此我记录了方法 2。

如果您有时间，请尝试用一批用户测试这两种方式，看看是否有效。如果需要，我可以编写一个 SQL 查询来确认更新是否按预期生效。请随时告诉我您的想法。

---

_[View the full topic](https://meta.discourse.org/t/how-to-set-the-same-sidebar-categories-for-all-the-users/402479)._
