Developing Discourse Themes & Theme Components

Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components.

This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to:

Themes vs. Theme Components

Discourse Themes can be used to customize the frontend user experience using CSS and JavaScript. Each theme has its own git repository, and community admins can generally install and manage them via the Discourse admin panel, even on shared hosting platforms.

Theme Components are themes which are intended for use alongside other Theme Components, as part of an overall Theme. From a development point of view, Theme Components and Themes are almost identical. In these guides, the phrase “Theme” and “Theme Component” are used interchangeably.

Prerequisites

Firstly, make sure you understand how to use existing themes and theme components in Discourse. Using ready-made themes is the quickest and safest way to customize your community. If you need more, then it’s time to consider writing your own theme.

As part of Discourse’s overall architecture, Discourse Themes are built using standard HTML, CSS, JavaScript technologies, and make use of Ember concepts for more advanced UIs. These reference guides assume a base-level understanding of these technologies, and link out to external references where possible.

Discourse is a fast-moving project, and as such any custom theme will require maintenance over time. Make sure you consider this as part of your planning & development processes.

Getting Started

Frontend Customization

More!

Check out the rest of the Developer Guides !


This document is version controlled - suggest changes on github.

142개의 좋아요
Get started with Theme Creator and the Theme CLI
Structure of themes and theme components
Theme Developer Quick Reference Guide
Executing js after DOM loaded
Request: House Ads Plugin
What do you use to make animated/gif instructions?
Is there any way to hyperlink to the middle of a post?
Getting Topic Information
Add long site description to about page
Add JS code to post?
My script is not working
Any options for over-riding the username restrictions?
Include assets (e.g. images, fonts) in themes and components
Landing page customization
How to add JS in After Header?
Versatile Banner
ItemList Schema Structured Data Error
How to remove the number of months in the category section
How to inject HTML code in the head only on home and post pages
What's the fastest and easiest way to add a persistent javascript file or snippet
What do I need before signing up?
Add CurrentThemeId into Body Css Classes
Unable to use <script> with plugin outlets
Custom banner for discourse channel
Difficulties in correctly adding external JavaScript
Redirect Page for External URLs
How to have a Tag Column?
How do you add custom JS to a theme?
How can i add image in login and register box
Adding Custom Background CSS
Changing layout with themes
Image not filling header container
Profile Image Looks Blurry After Resizing
Render modal from theme client-side plugin API
Is there an event that fires when topic-lists are reloaded?
Floating "New topic" button
Introducing Font Awesome 5 and SVG icons
Working on first plugin; does not work. Using the pirate-speak plugin as a base
Disable right click on images
Theme Creator Web Dev Help
Customize template used by post widget
Request modification homepage
How would updating effect custom overrides?
How to simplify DM's to individuals
Using CSS to suppress vote options from view results with zero votes
Click counter missing for some internal links
How to create custom theme component?
Can a Discourse theme/template be customised to have this format?
I would like to change the template completely
Make Tag Dropdown Retain Focus After Tag Picked; Client-Side API Questions
Add custom anonymous mode button
Introducing Font Awesome 5 and SVG icons
Can't add new class to topic page elements using jQuery?
Adding a second tag description
Change Default Avatar in home page (for original author avatar)
A native sidebar system
Topic list like on wyzecam
Advice for starting with Discourse development
How to remove the "topics _per week_" count?
Google Material icons
Modifying head_tag.html template
Integrate adbutler / Java script with the adplugin
Put user custom field on the user account page
Can you make Discourse look like medium.com?
Como faço para entender esse fórum? (How do I understand this forum?)
How to create a theme (if I am a pure end user)
How to create a theme (if I am a pure end user)
Override values for auto-generated color variables
Editing The 'Accept Invitation' Page Template
What HTML can you customize?
Wiki Threads - Linking Within A Single Post
reopenWidget throws error
How to add the two floating sidebar banners?
Fakebook Theme
Add a "curated personal learning" page for users
Change "+ New Topic" button to match styling of "Reply" button
Question about modifying a theme we're using
Place for total coding beginners to learn how to customise?
Is it possible to change via CSS the Category Moderator shield?
Newbie help accessing code
Per-category Terms of Service
New lines in the composer's reply placeholder?
Fetch third party data for topic list
Discourse Category Headers theme component
Is there a theming 'map'? (An easy way to find plugin-outlets etc)
Call function on page change
Making custom changes to a raw template
Timeline overlapping "Suggested Topics"
Is it possible to modify a function in a helper via the plugin or theme component system?
Different category and sub-category order behaviour
Help me to append html code on Hamburger Section
(old) method for adding languages to highlight.js on Discourse
Is there a way to overwrites all colors?
Customise Sign-up form design
Possible to share a post by save a picture with a QR code?
Dumb question: do I want to make a theme, plugin or component?
What are the different ways to customize content inside a post (custom attributes and such)
I’d like to start developing for Discourse, where should I begin?
Insert text or images anywhere on your site using CSS pseudo-elements
How to access the uncooked content from a theme component?
reopenWidget throws error
How to make a website with Discourse
How might we better structure #howto?
Best strategy for finding the right template to edit?
Is there a recommended way to get the current username from a post?
Theme-Component v Plugin: What's the difference
Theme-Component v Plugin: What's the difference
Theme-Component v Plugin: What's the difference
How to organize code entered from the head tag?
Creating Parsing Extensions
Can't add new class to topic page elements using jQuery?
Can parameters be injected from the template to a widget action?
How to override a template.hbs from a plugin
A11y for Categories
Navigating to local URL fragment doesn't modify browser history
Wide image extending until search icon?
Customize "Create a New Topic " and "Create Topic" Button
How to add Google Custom Search Engine to Discourse
How to add Google Custom Search Engine to Discourse
Add Login / Signup Buttons to custom HTML
What's the fastest and easiest way to add a persistent javascript file or snippet
Sticky user card contents theme
Wordpress in header, Discourse in footer ? Both sticky
Ability to place custom fields in post header?
How to put button in the corner of the screen?
Welcome page image
Custom header colour and category icons and login button
Theme Creator Broken Again?
Disabling full name changes
Can I change the URL of the main logo?
How to register a helper in Discourse?
Home page customization: latest + featured
Template overrides no longer working
Styling front page category title & nav container background
Any way to remove columns in the users page?
Category descriptions not showing up on mobile
Spawn navigation on topic pages
Selectively hiding numbers
Allow users to hide like counts
0 likes in latest section
0 likes in latest section
Can I override app/views/layouts/application.html.erb from a plugin?
About the Theme category
About the Theme component category
How customize the appearance of sections like Amazon?
How to show HTML view and how to update data in HTML view
Confused about remotely loaded javascript content
api.decorateWidget - how can I find the template's names?
api.decorateWidget - how can I find the template's names?
Autocompletion for a user field at signup
Is there a way to add a website navigation menu above Discourse header?
How can I add a menu item
Enhanced category-box display component
Interactive SVG using <object>?
Discourse for self hosting
FKB Pro - Social theme
Javascripts targeting the footer doesn't work after page transitions
How can I change the HTML template of advanced search?
JS widget/code (first post)
Next js application as custom front end replacement
Help needed with theming and logo
Is it possible to replace the h3 tag with another tag in category name titles?
Add project description to login page
Custom text at top of search results page
Landing page customization
How to add a custom url text link on the login page
Custom discourse with limited features
[PAID] Onedrive file picker theme component
How can I call third party apis in discourse
How to correctly listen on post-stream update
Modifying DirectoryTables
Topic List Previews (legacy)
How to add Javascript to Footer Of Posts?
Website Integration
Is there a comprehensive list of customizable components?
Need help to emulate old forum
How to show Full Name in Embeds
How to display full name in comments embeds
How can I change the background of a certain topic?
Disable media download in onebox
How to bring in Latest topics when using category boxes
Banner text customization for Subscriptions plugin
How do I create a new Sign Up / Login Button?
How do I get started with Discourse development as a regular end user with no programming experience?
Lag in selecting text
Big vBulletin forum migration project
What is the name of this theme?
How to customize discourse composer editor
User profile page / CSS class for groups / how to add it to page?
Insert the hbs template into the plugin outlet on the page -> user-preferences-interface to user-preferences-account
How to reopen header-contents widget?
Edit Code
Add custom content on anywhere on discourse
Add a custom header with a dropdown menu
Add settings to your Discourse theme
Contributing to Discourse
Ad Banner / HTML code in the right gutter
Changing the login Page for Custom Themes
How to get DOM elements and change onClick functionality
Designer's Guide to getting started with themes in Discourse
Making a search icon with a theme
Is there a way to change nav toggle menu on mobile to normal text like on desktop?
How to edit topics/show.html.erb
Links into the header block
Customize the header with links, icons, or menus
Import Sql file but can't see Custom theme folder in local development
Locations Plugin :earth_africa:
Author name plus avatar
Sticky footer to the bottom, pure CSS solution
The best way to make small ui modifications
Customize topic list entries (sorting, grouping, filtering) for better organization
Hamburger-categories widget does not mount?
Hamburger-categories widget does not mount?
Can I make a custom button with CSS and HTML?
How to use themes?
How to put javascript in Discourse theme?
Implementing a countdown bbcode
Customize Your Site Branding
How can I pull the currently open topic's list of tags?
How can I pull the currently open topic's list of tags?
Any existing theme with categories on top as cards?
Deleting permissions | Create new Topic
Category page layout in 2 columns
Mobile View Loading different HTML as compared to Desktop
How can I have a gif be the embed thumbnail on a topic/post
Disable topic buttons converting to select on mobile
Is there a way to create a footer on the home with icons? (Only for mobile users, and overlapping the topics)
Can anyone help me with this home modification code?
How to make changes on backend side of discourse application using rails
Introduction to Discourse Development
How to add btn before "sign in"
Discourse blog (article and comments)
Custom tags?
Chat look customization
Minimizing Maintenance on Theme Customizations
Sidebar link / top button to PM admin
Can we delete all 'Automatically Bumped' msgs in one go?
Why no view count on mobile
Adding custom html under header (d-header-wrap) instead of main-outlet
How to pass a component setting as a value to an attribute?
Show login first on invitation form
I want to learn how to program for Discourse
Cannot mount the "post-avatar" on the "topic-above-post-stream" plugin outlet
I need help to edit the sidebar
Help with Blocked words and custom button links
What Themes are being used for these Discourse forums?
How can one add a toggle button to the post menu and implement an action for that toggle button in a Discourse plugin?
How to copy the files/data/posts from production to Staging instance
Silent link seems can't handle #anchor links
Right Sidebar Blocks
New th in topic table
How to change category names via theme-component
How to develop new Theme
Silent link seems can't handle #anchor links
Is there a way to remove the pop-ups when making a new topic?
Looking for the perfect theme
How do I go about making a very customized theme?
Need help integrating code wrote on Edittext to the Discourse
Need help integrating code wrote on Edittext to the Discourse
I want to add adsense code in <head> for activet adsence account
How to change new topic's layout on mobile side?
JavaScript Execution Time
Search section like on Reddit?
Air Theme
Can you change the color of customizable text?
Policy notice: no basic HTML / CSS questions please
How to resize 'Modern Category + Group Boxes' thumbnail via CSS
How can I change the main CSS codes?
How can I create a Discourse that's just like Stemaway.com?
Using api from custom component
Adding new columns to user lists in groups
Need help to **getSelected** and **replace** from Toolbarevent
Gallery of discourse customization
Embedding a whole Discourse forum on another site in an <iframe>
Air Theme
Error when clicking on the homepage logo
Developing Discourse Plugins - Part 1 - Create a basic plugin
How do I add category banners?
List of components or PluginOutlets with explanatory documentation
Add localizable strings to themes and theme components
Develop a theme
Is it possible to change the icon for staff notices?
Customizing Sign-up and Log in
Handlebars template override all in the same html file?
Show sidebar to anonymous user + Welcome area in central theme
I'm trying to run discourse app locally in production env without docker
When to use a plugin vs theme component?
Challenges creating a custom color palette
Adding preview screenshots to Discourse themes
Theme Component for text over pics?
Webinar: Love Your Community
Sign Up button doesn't show up anymore with decorateWidget
Controlling site settings with themes
Customize user card
Templating of my "component" broke. How do I fix it?
Why am I finding Discourse so difficult to customize?
Air Theme
Air Theme
How do the `@import`'s work with SCSS?
Hide flag actions for current user when they're flagged or the flagger
Add localizable strings to themes and theme components
Login modal misaligned due to ratings plugin
Minima Theme
How can I edit My Login Page
Add category moderators with the API?
How to create a Handlebar helper function
Need help setting up category list images
Self Service Badges?
Why are posts withdrawn instead of being deleted immediately?
How can I apply new changes when edit JS file in production?
Avatars by posts in Category with Featured Topics
Feature idea: Parameterized macros (or, "smart replacements")
Replacing Details Toolbar Button?
Feedback on my forum
Customisability in discourse?
Applying a custom header to Discourse site
How to add customer HTML after "post_1"
Add text to top navbar to the left of login/signup buttons
Add text to top navbar to the left of login/signup buttons
Extending the About page
Description of the category is not displayed at mobile version
Custom structure and more questions
Widget's user awareness
CSS selector to separate posts by current user
Which is Better? Discourse or Flarum?
Javascript assets in a theme component
Can I update the user field automatically via API or otherwise?
Help changing color of buttons
Using Discourse variables to personalize embedded Typeform
How to get specific category banners with subcategories listed below
Category name after category image
Have users complete form when creating a topic?
How difficult would it be to make the Discourse UI more like Flarum?
How do we add buttons next to the "New Topic" button?
Can I use a theme I created without allowing it to be used by others?
Discourse-webpack: A boilerplate for developing JS-heavy Discourse components
Need plugin code for customised dicourse header
How to make a newline in category description
Home page category lumping
How to make your side have a side-bar and external links
Where to place ad script?

The PluginApi - modifyClass() section 섹션에 오래되었거나 죽은 링크와 참조가 정말 많습니다…

이 파일은 너무 많이 변경되어 checkReplyLength가 더 이상 존재하지도 않습니다…

그리고 같은 섹션의 후반부에서는:

이 링크는 단순히 “404 - 페이지를 찾을 수 없음” 오류만 발생합니다…

그 후로 이 문서를 사용하는 것을 포기했습니다…

4개의 좋아요

게시글이 새 주제로 분리되었습니다: 사용자 카드 템플릿 또는 위젯?

이 부분에 대한 문서가 약간 구식이네요. (api.modifyClass가 pluginId 누락에 대해 경고도 합니다.) about-page가 로드될 때 스크립트를 실행하려면 어떻게 해야 하나요? 아래 코드는 작동하지 않는 것 같습니다(에러는 발생하지 않아요). 다른 컴포넌트에서는 결과가まちまち였습니다. 감사합니다.

<script type="text/discourse-plugin" version="0.11.1">

api.modifyClass("component:about-page", {
  pluginId: 'discourse-about-theme',

  didInsertElement() {
    this._super(...arguments);
    console.log("Welcome to the about page!");
  }

});

</script>
1개의 좋아요

안녕하세요 :wave: about-page가 이제 .gjs 파일이 되었으며, 이는 해당 방식으로 더 이상 수정할 수 없음을 의미합니다. 변경 사항을 적용하려면 해당 페이지에서 사용할 수 있는 커넥터 중 하나를 사용해야 합니다.

플러그인 아웃렛 위치 테마 컴포넌트를 통해 이를 쉽게 확인할 수 있거나, 파일 내 <PluginOutlet>을 직접 확인해 볼 수도 있습니다.

4개의 좋아요

정말 감사합니다. 이해가 됩니다. 대신 커넥터를 사용했는데, 잘 작동합니다.

2개의 좋아요

이 가이드가 아직도 정확한가요? 테마 컴포넌트를 만들어 보려고 전체를 읽었는데, 샘플 테마 컴포넌트 중 그 지시를 따르는 것이 하나도 없었습니다. 예를 들어 discourse-brand-header 테마 컴포넌트를 살펴보면, header.html에서 api.createwidget와 같은 것을 사용하던 것에서 초기화 프로그램(Initializers), 컴포넌트(Components) 등을 사용하는 완전히 다른 코드로 리팩토링된 것 같습니다. 매우 복잡한 코드입니다. 가이드에서는 위젯을 위한 API 메서드를 사용하라고 하지만, 실제로는 어떤 컴포넌트도 전혀 그렇게 사용하지 않습니다. 컴포넌트를 사용하는 방법에 대한 업데이트된 가이드나 유사한 것이 있을까요?

수정: 위젯 API가 곧 사라진다고 하는데, 대신 무엇을 사용해야 하는지에 대한 가이드가 있나요? 여기의 전체 가이드가 비추천(deprecated)된 코드를 기반으로 작성된 것 같습니다.

4개의 좋아요

맞아요. 가이드는 업데이트되어야 합니다. 하지만 파일 구조 같은 일부 내용은 여전히 꽤 관련이 있습니다.

2개의 좋아요

네, SCSS는 관련이 있는 것 같지만, 그 외에는 모든 샘플 테마 컴포넌트가 Components를 사용하며, 여기서 가르치는 내용과는 완전히 다른 코드베이스로 리팩토링된 것 같습니다. 플러그인 API 섹션에서 링크된 모든 컴포넌트를 확인해 보았는데, 하나같이 여기서 가이드로 가르치는 방식과는 전혀 다른 방식으로 리팩토링되어 있었습니다. Widgets는 더 이상 전혀 사용되지 않습니다. 전부 Components입니다. Widgets가 사라지는 상황에서, 새로운 Components를 실제로 올바르게 사용하는 방법에 대한 가이드가 있을까요?

2개의 좋아요

예를 들어 방금 이런 게시물을 보았습니다: Upcoming Header Changes - Preparing Themes and Plugins - 그래서 레거시 위젯에서 Glimmer 컴포넌트로 모든 것을 리팩토링한 건가요? 하지만 이 튜토리얼은 전부 레거시 위젯에 대한 내용입니다. Glimmer 컴포넌트란 정확히 무엇이며, 관련 가이드가 있나요? 레거시 위젯으로 개발을 시작하기 전에 이걸 알게 되어 다행이라고 생각합니다. 이 가이드에 위젯이 레거시이며 더 이상 사용되지 않는다는 주의를 추가해 주시면 어떨까요?

2개의 좋아요

네, Glimmer가 새로운 Ember 컴포넌트라는 점은 알겠어요. 그런데 Discourse TOC 코드를 살펴봤는데, 제발… 이전에 10줄 정도였던 코드가 이제는 여러 파일에 걸쳐 수백 줄로 늘어났고, 복잡한 클래스, 데코레이터 등이 사용되고 있더라고요. Ember가 React처럼 '모멘트’를 맞이해서 다시 정말 복잡한 방향으로 가자고 결정한 것 같아요. 테마 컴포넌트도 이제는 간단한 위젯 API로 쉽게 만들 수 있는 것이 아니라, 방대한 양의 코딩이 필요한 것 같습니다…

2개의 좋아요

@ddsgad 네, 맞습니다. 이 가이드의 대부분이 매우 오래되었습니다. 최근 일반 문서 개선 작업을 진행 중이며, 향후 몇 주 안에 이 가이드를 업데이트하거나 교체할 예정입니다.

말씀하신 대로 DiscoTOC와 같은 실제 사례가 좋은 참고 자료가 될 수 있습니다. 그리고 여기 더 최신 상태인 특정 가이드들이 있습니다:

Ember 및 그 컴포넌트에 대한 일반적인 정보는 Ember 가이드를 참고하는 것을 권장합니다.

6개의 좋아요

링크들 감사합니다. 정말 도움이 됩니다. 현재 우리는 기본적으로 discourse 주제(첫 번째 게시글)의 요소를 커스터마이징하여 더 나은 디자인을 만들고 있는데, 덕분에 기본적으로 순수 Vanilla JavaScript(querySelectorAll 등)와 SCSS만으로 거의 모든 작업을 처리할 수 있었습니다. 그래서 당분간 이 방식을 유지할 것 같습니다.

3개의 좋아요

OP의 길고 오래된 튜토리얼은 이제 더 일반적인 소개/가이드 정보로 대체되었습니다. 여기에는 훨씬 더 현대적인 테마 개발 패턴을 따르는 완전히 새로운 7단계 튜토리얼에 대한 링크도 포함되어 있습니다.

5개의 좋아요

모든 내용을 읽었고, 재미있게 읽었습니다! 잘 설명되어 있었고, 아주 좋은 입문 자료였어요!

3개의 좋아요

이런 가이드 정말 좋아요! api.decorateCookedElement를 드디어 파악했습니다. 또 도움되는 문서 감사합니다!

4개의 좋아요