Get started with Theme Creator and the 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 Developing Discourse Themes & Theme Components


This document is version controlled - suggest changes on github.

42개의 좋아요

Hi. I’m trying to follow these instructions but I keep hitting a wall. After adding the API key I see the following:

/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>'

Any idea why?
TIA

1개의 좋아요

Hi!
This tool does not support Ruby 3.2 yet because of changes in the language. We have a fix in the works, but Ruby 3.1.x works in the meantime.

6개의 좋아요

Ah, that’ll be why then.
Thanks :slight_smile:

1개의 좋아요

This is now fixed - discourse_theme should work under Ruby 3.2.x from gem version 0.7.4 and up :slight_smile:

3개의 좋아요

Wow, that was quick :open_mouth:
Thank you. I did manage to get it working with the help of my line manager who suggested:

rbenv install 3.1.3
rbenv shell 3.1.3
gem install discourse_theme

Which didn’t actually work until I closed the terminal tab and re-opened it again.

discourse_theme watch가 더 이상 실시간 재로드(live-reload)를 하지 않는 건가요? 예전에는 테마를 저장하면 자동으로 새로고침이 되었는데, 지금은 탭을 수동으로 새로고침해야 합니다. 콘솔에 원인을 가리키는 내용이 아무것도 없습니다.

1개의 좋아요

며칠 전에 변경 사항이 있었습니다.

Live Reload in Production 에도 관심이 있으실 수 있습니다.

4개의 좋아요

https://discourse.theme-creator.io/ 에서 제 테마를 올바르게 미리 보는 방법을 이해하려고 합니다.

discourse_theme watch는 정상 작동하며, 제 변경 사항이 미리보기 URL에 동기화되고 있습니다. about.jsoncolor_schemes를 추가한 테마를 스캐폴딩했습니다. /me/theme의 테마 선택 상자에는 해당 스킴이 표시되지만, 실제로 스킴/팔레트를 선택하여 볼 수 없고, 제가 직접 지정하지 않은 기본 스킴인 "Light"에 고정되어 있습니다.

about.json에서 정의한 명명된 색상 스킴은 /me/preferences/interface에도 표시되지 않습니다.

무엇이 잘못되었나요?

감사합니다!