# 弃用主题和插件中的 .hbs 文件扩展名

**URL:** https://meta.discourse.org/t/deprecating-hbs-file-extension-in-themes-and-plugins/398896
**Category:** Development
**Tags:** dev-news
**Created:** [2026年三月20日 16:48 UTC](https://meta.discourse.org/t/deprecating-hbs-file-extension-in-themes-and-plugins/398896 "2026-03-20T16:48:11Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2026年三月20日 16:48 UTC](https://meta.discourse.org/t/deprecating-hbs-file-extension-in-themes-and-plugins/398896/1 "2026-03-20T16:48:11Z")

</div>

在最新版本的 Discourse 中，在主题和插件中使用 `.hbs` 文件已被弃用。对这种文件格式的支持将在下一次 ESR 版本发布后移除。

Handlebars 模板应替换为更现代的 `.gjs` 格式，这提供了更好的开发体验，并将在未来版本的 Discourse 中实现显著的性能提升。

对于简单的情况，请与 [https://ask.discourse.com/](https://ask.discourse.com/) 分享您的代码，并请它重写为 `.gjs` 格式。

对于更复杂的情况，可以使用此代码转换器自动更新：

> [@Automatically updating themes and plugins to .gjs file format](https://meta.discourse.org/t/automatically-updating-themes-and-plugins-to-gjs-file-format/368051?u=david):
>
> In the latest version of Discourse’s standard linting config, we’ve enabled the require-strict-mode ember-template-lint rule. This will raise a linting error for any .hbs files. To resolve the warnings, you should convert all your component, route, and connector templates to .gjs files. To make this easy, we’ve built the [discourse-gjs-codemod](https://github.com/discourse/discourse-gjs-codemod), which builds on top of Ember’s [@embroider/template-tag-codemod](https://github.com/embroider-build/embroider/tree/main/packages/template-tag-codemod). To use the codemod, first ensure that your linting dependencies are up-to-date by copyin…

---

_[View the full topic](https://meta.discourse.org/t/deprecating-hbs-file-extension-in-themes-and-plugins/398896)._
