Commencez avec Theme Creator et le Theme CLI

This topic will walk you through how to use the Theme CLI with our Theme Creator site to develop a theme and preview your changes on a live Discourse site.

  1. Sign up for an account here on Meta if you haven’t already

  2. Log in to Theme Creator

  3. Install the Theme CLI via the instructions here

  4. Create a new theme on Theme Creator by:

  5. Click advanced, then edit locally, and retrieve API key.

    Copy the API key that is generated.

  1. Go back to your command line and type discourse_theme download example-folder, where example-folder is where your theme will be stored locally. Follow the prompts.

    • Enter https://discourse.theme-creator.io as the root URL of your Discourse site.

    • Enter your API key from the previous step when prompted.

    • Continue following the prompts and select the theme you created in step 4.

    • Enter yes when asked if you’d like to start watching your theme.

  2. Now your local theme folder is being watched for changes, which will be automatically uploaded to Theme Creator. You can open a preview of your theme by clicking preview in your theme’s settings on Theme Creator.

  3. To stop watching for changes, hit ctrl + c in your command line window. To start watching for changes again type discourse_theme watch example-theme.

:tada: You now have a local theme directory you can edit and see your changes live!

For an in-depth look at how themes are structured and what you can do, check out our Beginner's guide to developing Discourse Themes


This document is version controlled - suggest changes on github.

42 « J'aime »

Bonjour. J’essaie de suivre ces instructions mais je me heurte à un problème. Après avoir ajouté la clé API, je vois ceci :

/usr/local/lib/ruby/gems/3.2.0/gems/discourse_theme-0.7.3/lib/discourse_theme/cli.rb:100:in `run': undefined method `exists?' for Dir:Class (NoMethodError)

        FileUtils.mkdir_p dir unless Dir.exists?(dir)
                                        ^^^^^^^
Did you mean?  exist?
        from /usr/local/lib/ruby/gems/3.2.0/gems/discourse_theme-0.7.3/bin/discourse_theme:6:in `<top (required)>'
        from /usr/local/lib/ruby/gems/3.2.0/bin/discourse_theme:25:in `load'
        from /usr/local/lib/ruby/gems/3.2.0/bin/discourse_theme:25:in `<main>'

Une idée de pourquoi ? Merci d’avance.

1 « J'aime »

Salut !
Cet outil ne prend pas encore en charge Ruby 3.2 en raison de changements dans le langage. Nous avons un correctif en cours, mais Ruby 3.1.x fonctionne en attendant.

6 « J'aime »

Ah, ça explique alors.
Merci :slight_smile:

1 « J'aime »

Ceci est maintenant corrigé - discourse_theme devrait fonctionner sous Ruby 3.2.x à partir de la version gem 0.7.4 et supérieures :slight_smile:

3 « J'aime »

Wow, c’était rapide :open_mouth:
Merci. J’ai réussi à le faire fonctionner avec l’aide de mon chef de service qui a suggéré :

rbenv install 3.1.3
rbenv shell 3.1.3
gem install discourse_theme

Ce qui n’a en fait pas fonctionné avant que je ne ferme l’onglet du terminal et que je ne le rouvre.