docs/developer-guides/docs/05-themes-components/06-theme-structure.md
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: https://github.com/SamSaffron/discourse-simple-theme
The git repository will be checked for updates (once a day), or by using the <kbd>Check for Updates</kbd> button. When changes are detected the <kbd>Check for Updates</kbd> button will change to the <kbd>Update to Latest</kbd>.
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}.gjs
javascripts/{anything}.hbs
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.
https://meta.discourse.org/t/splitting-up-theme-scss-into-multiple-files/115126
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: https://meta.discourse.org/t/how-to-add-settings-to-your-discourse-theme/82557?u=osama.
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.
Check out the other articles with the #themes::tag tag.
:information_source: See also:
Last Reviewed by @SaraDev on [date=2022-08-15 time=14:00 timezone="America/Los_Angeles"]