# Discourse 开发者指南(英文原版) > Discourse 是广泛使用的开源论坛系统。本书(英文)是官方开发者指南,从本地开发环境与代码结构讲到插件与主题的开发、测试和发布,面向想定制和扩展 Discourse 的开发者。 - Canonical URL: https://docs.cocobook.com/books/discourse - Category: 开源参考文库 (reference) - License: GPL-2.0-only - Last Updated: 2026-11-15 - Search JSON API: https://docs.cocobook.com/cocobook/search?format=json&q= - MCP Endpoint: https://mcp.cocobook.com/v1/docs - Agent Skill Map: https://docs.cocobook.com/books/discourse/SKILL.md - Companion Language (中文 / zh-CN): https://docs.cocobook.com/books/discourse-zh ## 目录地图(Chapters & Pages) ### [introduction](https://docs.cocobook.com/books/discourse/chapter/introduction) - [Introduction](https://docs.cocobook.com/books/discourse/page/introduction) — Discourse is a modern and highly-customizable platform for building communities. This… ### [development environments](https://docs.cocobook.com/books/discourse/chapter/development-environments) - [Dev Container](https://docs.cocobook.com/books/discourse/page/01-devcontainer) — Dev Containers is an open standard for configuring a development environment inside a… - [GitHub Codespaces](https://docs.cocobook.com/books/discourse/page/02-github-codespaces) — is a very fast way to get started with Discourse development. Their… - [Docker setup](https://docs.cocobook.com/books/discourse/page/03-docker-setup) — Developing using Docker Since Discourse runs in Docker, you should be able to run Dis… - [macOS setup](https://docs.cocobook.com/books/discourse/page/04-macos-setup) — :warning: This guide covers installation instructions for a macOS development environ… - [Ubuntu/Debian setup](https://docs.cocobook.com/books/discourse/page/05-ubuntu-debian-setup) — :warning: This guide covers installation instructions in a development environment. F… - [Windows setup](https://docs.cocobook.com/books/discourse/page/06-windows-10-setup) — :information_source: This tutorial has been tested on Windows 10 and 11. To set up a… - [Non-Docker plugins](https://docs.cocobook.com/books/discourse/page/07-non-docker-plugins) — (This guide only covers non-docker dev install. For Docker dev :whale: see https://me… - [Local setup](https://docs.cocobook.com/books/discourse/page/08-local-setup) — So you want to set up Discourse locally to hack on and develop with? This root guide… - [Multisite setup](https://docs.cocobook.com/books/discourse/page/09-multisite-setup) — It's possible to run discourse in multisite mode in development. A multisite server u… - [Fedora setup](https://docs.cocobook.com/books/discourse/page/10-fedora-setup) — This guide has been tested against a fresh install of Fedora 31 and 33, but may work… ### [code internals](https://docs.cocobook.com/books/discourse/chapter/code-internals) - [Ember components](https://docs.cocobook.com/books/discourse/page/01-ember-components) — In the previous tutorial I showed how to configure both the server and the client sid… - [UI kit](https://docs.cocobook.com/books/discourse/page/02-ui-kit) — ui-kit is the layer of reusable, domain-free building blocks that core, plugins, and… - [Lint and format](https://docs.cocobook.com/books/discourse/page/03-lint-and-format) — Discourse uses lefthook for git hooks, and bin/lint as the main CLI entry point for r… - [Run test suites](https://docs.cocobook.com/books/discourse/page/05-run-test-suites) — Discourse has extensive frontend tests for core, plugins and themes. Once you have a… - [Version compatibility](https://docs.cocobook.com/books/discourse/page/06-version-compatibility) — 📖 Background Theme and plugin developers generally want to target the latest release… - [Ember object ownership](https://docs.cocobook.com/books/discourse/page/07-ember-object-ownership) — :warning: Importing getOwner from discourse-common/lib/get-owner is deprecated. To ac… - [JS performance](https://docs.cocobook.com/books/discourse/page/08-js-performance) — When working on client-side work in Discourse core/plugins/themes, it's important to… - [CI with GitHub Actions](https://docs.cocobook.com/books/discourse/page/09-ci-with-github-actions) — :mag: Overview To build a robust extension for Discourse, it can be wise to include C… - [Markdown extensions](https://docs.cocobook.com/books/discourse/page/10-markdown-extensions) — Discourse uses a Markdown engine called Markdown-it. Here are some dev notes that wil… - [Converting modals](https://docs.cocobook.com/books/discourse/page/11-converting-modals) — :information_source: If you're implementing a new Modal, check out the main docs here… - [DModal API](https://docs.cocobook.com/books/discourse/page/12-dmodal-api) — Discourse 3.1.0.beta6 ships with a brand new component-based API. DModal is part of t… - [JS API](https://docs.cocobook.com/books/discourse/page/13-pluginapi) — Discourse's JavaScript API allows themes and plugins to make extensive customizations… - [Plugin outlet connectors](https://docs.cocobook.com/books/discourse/page/14-plugin-outlet-connectors) — Discourse includes hundreds of Plugin Outlets which can be used to inject new content… - [modifyClass](https://docs.cocobook.com/books/discourse/page/15-modifyclass) — For advanced themes and plugins, Discourse offers the modifyClass system. This allows… - [Creating routes](https://docs.cocobook.com/books/discourse/page/16-creating-routes) — Over time Discourse has grown in complexity and it can be daunting for beginners to u… - [Authentication method](https://docs.cocobook.com/books/discourse/page/17-authentication-method) — Continuing from https://meta.discourse.org/t/future-social-authentication-improvement… - [Accidental serialization of ActiveRecord models](https://docs.cocobook.com/books/discourse/page/18-accidental-serialization-of-activerecord-models) — We've introduced a patch to prevent the accidental serialization of ActiveRecord mode… - [Overriding templates](https://docs.cocobook.com/books/discourse/page/19-overriding-templates) — Ideally, when customizing Discourse via themes/plugins, you should use CSS, the JavaS… - [Service objects](https://docs.cocobook.com/books/discourse/page/20-service-objects) — Overview A service is a small object that encompasses business logic for a given acti… - [System specs](https://docs.cocobook.com/books/discourse/page/21-system-specs) — Background Rails system specs are used to simulate the actions of a real user using t… - [FormKit](https://docs.cocobook.com/books/discourse/page/22-form-kit) — Basic Usage FormKit exposes a single component as its public API: . All other element… - [AppEvents Triggers](https://docs.cocobook.com/books/discourse/page/23-app-events-triggers) — AppEvents The AppEvent system in Discourse provides a pub/sub mechanism for handling… - [Transformers](https://docs.cocobook.com/books/discourse/page/24-transformers) — Discourse core includes a number of "transformer" hooks which can be used to customiz… - [Topic List Customization](https://docs.cocobook.com/books/discourse/page/25-customizing-topic-list) — The topic-list is one of the most-used and most-customized user-interfaces in Discour… - [CSS guidelines](https://docs.cocobook.com/books/discourse/page/26-css-guidelines-bem) — Background When writing CSS classes for Discourse components, themes, or plugins, we… - [JS type hinting & validation](https://docs.cocobook.com/books/discourse/page/27-types) — Discourse ships type information for its JavaScript code. This can provide inline doc… - [Designing for Devices](https://docs.cocobook.com/books/discourse/page/28-designing-for-devices) — This document outlines the APIs used to adapt Discourse's user interface for differen… - [Designing for Responsive Widths](https://docs.cocobook.com/books/discourse/page/29-designing-for-responsive-widths) — This document outlines the APIs used to adapt Discourse's user interface to different… - [Gesture primitives](https://docs.cocobook.com/books/discourse/page/30-drag-and-gesture-primitives) — ui-kit ships the input-driven gesture primitives: dragging a payload onto a target, r… - [Bundle splitting](https://docs.cocobook.com/books/discourse/page/31-bundle-splitting-for-plugins) — By default, every javascript module in a plugin is loaded when Discourse boots. This… - [Private modules](https://docs.cocobook.com/books/discourse/page/32-private-modules) — What -internals means A folder named -internals holds code that is not public API. It… - [Acceptance tests](https://docs.cocobook.com/books/discourse/page/04-acceptance-tests) — Automated tests are a great way to protect your code against future regressions. Many… ### [plugins](https://docs.cocobook.com/books/discourse/chapter/plugins) - [Basic plugin](https://docs.cocobook.com/books/discourse/page/01-basic-plugin) — Building a plugin in Discourse can be really simple, once you learn a couple of quirk… - [Plugin outlet](https://docs.cocobook.com/books/discourse/page/02-plugin-outlet) — Previous tutorial: https://meta.discourse.org/t/developing-discourse-plugins-part-1-c… - [Site settings](https://docs.cocobook.com/books/discourse/page/03-site-settings) — Previous tutorial: https://meta.discourse.org/t/developing-discourse-plugins-part-2-c… - [Git setup](https://docs.cocobook.com/books/discourse/page/04-git-setup) — Previous tutorial: https://meta.discourse.org/t/developing-discourse-plugins-part-3-a… - [Admin interface](https://docs.cocobook.com/books/discourse/page/05-admin-interface) — Previous tutorial: https://meta.discourse.org/t/developing-discourse-plugins-part-4-s… - [Publish your plugin](https://docs.cocobook.com/books/discourse/page/07-publish-your-plugin) — Previous tutorial: https://meta.discourse.org/t/developing-discourse-plugins-part-6-a… - [New locales](https://docs.cocobook.com/books/discourse/page/08-new-locales) — Usually the best way to add a new language to Discourse is by creating a pull request… - [Chat integration](https://docs.cocobook.com/books/discourse/page/09-chat-integration) — discourse-chat-integration abstracts away the boilerplate for integrating Discourse w… - [markdown-it extension](https://docs.cocobook.com/books/discourse/page/10-markdown-it-extension) — markdown.it the CommonMark engine used by Discourse has a wide array of plugins Heade… - [Rails autoloading](https://docs.cocobook.com/books/discourse/page/11-rails-autoloading) — Many plugins include lots of class definitions inside plugin.rb, or use require_relat… - [Acceptance tests](https://docs.cocobook.com/books/discourse/page/06-acceptance-tests) — Previous tutorial: https://meta.discourse.org/t/developing-discourse-plugins-part-5-a… ### [themes components](https://docs.cocobook.com/books/discourse/chapter/themes-components) - [Developing Themes](https://docs.cocobook.com/books/discourse/page/01-developing-themes) — Discourse Themes and Theme Components can be used to customize the look, feel and fun… - [Quick reference](https://docs.cocobook.com/books/discourse/page/02-quick-reference) — As themes grow more powerful, there's more to remember about how they work. We have l… - [Designers guide](https://docs.cocobook.com/books/discourse/page/03-designers-guide) — So you're interested in in designing your own theme for Discourse? You've arrived at… - [Theme Creator](https://docs.cocobook.com/books/discourse/page/04-theme-creator) — This topic will walk you through how to use the Theme CLI with our Theme Creator site… - [Theme CLI](https://docs.cocobook.com/books/discourse/page/05-theme-cli) — The Discourse Theme CLI is a ruby gem that allows you to use your editor of choice wh… - [Theme structure](https://docs.cocobook.com/books/discourse/page/06-theme-structure) — Discourse supports native themes that can be sourced from a .tar.gz archive or from a… - [Multiple JS files](https://docs.cocobook.com/books/discourse/page/07-multiple-js-files) — Complex theme javascript can be split into multiple files, to keep things nicely orga… - [Multiple SCSS files](https://docs.cocobook.com/books/discourse/page/08-multiple-scss-files) — Themes and theme components are becoming steadily more powerful, and developers are g… - [Theme settings](https://docs.cocobook.com/books/discourse/page/09-theme-settings) — Discourse has the ability for themes to have "settings" that can be added by theme de… - [Objects for theme settings](https://docs.cocobook.com/books/discourse/page/10-objects-for-theme-settings) — We are introducing a new type: objects to the supported types for theme settings whic… - [Migrate settings](https://docs.cocobook.com/books/discourse/page/11-migrate-settings) — Introduction As of Discourse version 3.2.0.beta3, Discourse themes/components can lev… - [Theme metadata](https://docs.cocobook.com/books/discourse/page/12-theme-metadata) — You can add various pieces of metadata to a theme. Some are stored in the about.json… - [Core variables](https://docs.cocobook.com/books/discourse/page/13-core-variables) — Discourse is incredibly customizable! The goal of this topic is to show you how make… - [Localizable strings](https://docs.cocobook.com/books/discourse/page/14-localizable-strings) — For those looking to add custom languages and translations to a Discourse theme or th… - [E2E testing](https://docs.cocobook.com/books/discourse/page/15-e2e-testing) — Writing automated tests for themes is an important part of the theme development proc… - [Minimizing maintenance](https://docs.cocobook.com/books/discourse/page/16-minimizing-maintenance) — Discourse is highly customizable, enabling you to modify almost any aspect of its app… - [Font sizes](https://docs.cocobook.com/books/discourse/page/17-font-sizes) — Global font-size changes The simplest way to change the font size of your entire comm… - [Include assets](https://docs.cocobook.com/books/discourse/page/18-include-assets) — Themes and theme components allow you to handle uploaded assets such as images and fo… - [Custom icons](https://docs.cocobook.com/books/discourse/page/19-custom-icons) — You can replace a Discourse's default SVG icons individually or as a whole with your… - [Dark mode](https://docs.cocobook.com/books/discourse/page/20-dark-mode) — Previously, all colors in Discourse were stored as SCSS variables. To support automat… - [Theme modifiers](https://docs.cocobook.com/books/discourse/page/21-theme-modifiers) — As themes become more ambitious, we've been looking for ways to allow them to manipul… - [Pseudo-elements](https://docs.cocobook.com/books/discourse/page/22-pseudo-elements) — So, you want to insert some text or image in your Discourse site. Regarding the text… - [Font component](https://docs.cocobook.com/books/discourse/page/23-font-component) — Discourse supports importing themes containing assets from a remote repository. This… - [Highlight.JS language](https://docs.cocobook.com/books/discourse/page/24-highlight-js-language) — I've just added a hook to our HighlightJS code so now you can use the plugin API to a… - [Homepage content](https://docs.cocobook.com/books/discourse/page/25-homepage-content) — A very common situation you'll find yourself in as a theme developer is the need to c… - [Message format](https://docs.cocobook.com/books/discourse/page/27-message-format) — Guidelines for Translators In Discourse all Message Format strings have a key that en… - [Global icon changes](https://docs.cocobook.com/books/discourse/page/28-global-icon-changes) — This is an easy way to change a Discourse icon globally. Right click on the icon you… - [Alternative icons](https://docs.cocobook.com/books/discourse/page/29-alternative-icons) — By default, Discourse bundles icons from the excellent FontAwesome library. But there… - [Wiki post style](https://docs.cocobook.com/books/discourse/page/30-wiki-post-style) — A quick guide to change the style of your wiki posts: Change the background color: In… - [Color scheme](https://docs.cocobook.com/books/discourse/page/31-color-scheme) — Discourse now supports importing color schemes from remote repository. Here I will de… - [Navigation menu](https://docs.cocobook.com/books/discourse/page/32-navigation-menu) — If you are working on a theme for an existing site and want to preview how it will lo… - [Post content styles](https://docs.cocobook.com/books/discourse/page/33-post-content-styles) — Requirements :information_source: To be able to use these tips and tricks, you need t… - [Theme screenshots](https://docs.cocobook.com/books/discourse/page/34-theme-screenshots) — :bookmark: This guide explains how to add preview screenshots to your Discourse theme… - [Themeable site settings](https://docs.cocobook.com/books/discourse/page/35-themeable-site-settings) — allow a theme (not components) to override a small subset of… ### [general guides](https://docs.cocobook.com/books/discourse/chapter/general-guides) - [White-labelling mobile apps](https://docs.cocobook.com/books/discourse/page/01-white-labelling-mobile-apps) — Since we released the iOS and Android apps a number of people have asked expressed in… - [Custom automations](https://docs.cocobook.com/books/discourse/page/02-custom-automations) — :information_source: This is a draft, and may need some extra work. Vocabulary trigge… - [Public data dump](https://docs.cocobook.com/books/discourse/page/03-public-data-dump) — Given the advent of AI and the need for large datasets on local development machines,… - [AI evals](https://docs.cocobook.com/books/discourse/page/04-ai-evals) — Overview The Discourse AI plugin ships a Ruby CLI under plugins/discourse-ai/evals th… - [AI bot via API](https://docs.cocobook.com/books/discourse/page/05-ai-bot-api-use) — Overview Discourse AI exposes an admin/API endpoint for streaming an AI Agent reply o… ### [theme developer tutorial](https://docs.cocobook.com/books/discourse/chapter/theme-developer-tutorial) - [1 - Introduction](https://docs.cocobook.com/books/discourse/page/07-theme-developer-tutorial-01-introduction) — This tutorial will teach you how to create a Discourse Theme or Theme Component from… - [2 - Remote Theme](https://docs.cocobook.com/books/discourse/page/02-remote-theme) — In the last chapter, we created a basic theme via the Discourse admin interface. This… - [3 - CSS](https://docs.cocobook.com/books/discourse/page/03-css) — Technically, Discourse uses SCSS to author its stylesheets. However, we're increasing… - [4 - Outlets](https://docs.cocobook.com/books/discourse/page/04-outlets) — Discourse uses the Ember JS Framework for its user interface. On top of Ember, Discou… - [5 - Components](https://docs.cocobook.com/books/discourse/page/05-components) — In the last chapter, we explored how you can render Glimmer Components into plugin ou… - [6 - JS API](https://docs.cocobook.com/books/discourse/page/06-js-api) — In the last couple of chapters, we've explored how to use the JavaScript API to rende… - [7 - Conclusion](https://docs.cocobook.com/books/discourse/page/07-conclusion) — This tutorial has been a whistle-stop tour through the process of creating a Discours…