Estrutura de temas e componentes do tema

Discourse supports native themes that can be sourced from a .tar.gz archive or from a remote git repository including private repositories.

An example theme is at: GitHub - discourse/discourse-simple-theme: Sam's simple discourse theme

The git repository will be checked for updates (once a day), or by using the Check for Updates button. When changes are detected the Check for Updates button will change to the Update to Latest.

image

To create a theme you need to follow a specific file structure. These are the files you may include:

about.json (required)

common/common.scss
common/header.html
common/after_header.html
common/footer.html
common/head_tag.html
common/body_tag.html
common/embedded.scss

desktop/desktop.scss
desktop/header.html
desktop/after_header.html
desktop/footer.html
desktop/head_tag.html
desktop/body_tag.html

mobile/mobile.scss
mobile/header.html
mobile/after_header.html
mobile/footer.html
mobile/head_tag.html
mobile/body_tag.html

locales/en.yml
locales/{locale}.yml

stylesheets/{anything}/{anything}/{anything}.scss

javascripts/{anything}.js
javascripts/{anything}.hbs
javascripts/{anything}.hbr

assets/{asset_filename}

settings.yml

Any of these files :arrow_up: are optional, so you only need to create the ones you need.

For those looking to split theme SCSS into multiple files, that’s now possible.

For those looking to split up theme into multiple JS files, just add the JS files you want into the javascripts directory.

The about.json file structure is below, and you can see more information about it at https://meta.discourse.org/t/adding-metadata-to-a-theme/119205:

{
  "name": "My Theme",
  "component": false,
  "license_url": null,
  "about_url": null,
  "authors": null,
  "theme_version": null,
  "minimum_discourse_version": null,
  "maximum_discourse_version": null,
  "assets": {
    "variable-name": "assets/my-asset.jpg"
  },
  "color_schemes": {
    "My Color Scheme": {
      "primary": "222222"
    }
  },
  "screenshots": ["screenshots/light.jpeg", "screenshots/dark.jpeg"]
}

Instructions on how to add settings to your theme available here: Add settings to your Discourse theme.

To tell Discourse that you are going to add a theme component and not a full theme just add the line "component": true to the about.json file

The file structure matches the theme custom CSS / HTML.

Further reading

Check out the other articles with the #themes::tag tag.

:information_source: See also:


Last Reviewed by @SaraDev on 2022-08-15T21:00:00Z


This document is version controlled - suggest changes on github.

62 curtidas
Alien Night Theme - A free Dark Theme for Discourse
Override values for auto-generated color variables
How to modify the header HTML, but still remaining the default founctions
Custom user fields show on Activity, but not Summary page
Add Unsolved button to top menu using custom HTML
Color Scheme Contest (with Prizes!)
Create and share a font theme component
How do I get started with Discourse development as a regular end user with no programming experience?
Custom assets upload folder?
Add support for theme settings
Some basic questions about discourse and rails
Designer's Guide to getting started with themes in Discourse
Create and share a color scheme
Split up theme SCSS into multiple files
Adding metadata and screenshots to a Theme
Theme Developer Tutorial: 2. Creating a remote theme
Mobile View Loading different HTML as compared to Desktop
Developing Discourse Themes & Theme Components
Minimizing Maintenance on Theme Customizations
Need help with theme component Github
Allow users to select new color palettes
Challenges creating a custom color palette
Automatic dark mode for embedded comments as well?
Push to digital ocean from command line and rebuild
Battle Axe - A free theme by the Tappara.co hockey community
Beginner's guide to using Discourse Themes
Discourse deployment using github or bitbucket?
How to remove sticky top bar?
Do you have original customisations?
Add custom content that only appears on your homepage
Highlight color
Timefuser Theme
Add settings to your Discourse theme
Compact member list
Understanding the development/deployment process
CSS Theme Contest (with Prizes!)
How to bring in Latest topics when using category boxes
Need to include PGN (chess game notation) in a post
Custom header colour and category icons and login button
Theme Developer Quick Reference Guide
Add settings to your Discourse theme