How are theme setting fields created?

(Biscuit) #1

When you import the theme below from Github, “theme settings” appear set under Customize > Theme > Theme_Name.


The Github files include a YML file with the theme settings inside it. The “Import theme” process presumably uses that YML file to make the setting fields appear. But, when I’m writing my own theme (not plugin), how do I create theme settings / parameters like this?

(Taylor) #2

This should be what you are looking for :slightly_smiling_face::

(Biscuit) #3

How did I miss that topic!

Looks like it can’t be done via the interface and requires the files to be placed on Github. Never posted on Github before, so will have to give it a try, to test myself.

Thank you.

(Taylor) #4

No problem :slightly_smiling_face:

You don’t technically need to do anything on GitHub, the Discourse Theme CLI (console app to help you build themes) is really all you need to get started. It’s an extremely handy tool and easy to set up. I highly recommend giving it a try!

(Sarah) #5

Does anyone know how one would access variables in the theme settings in Javsscript?

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

I keep getting “themesettings is not defined” in the dev tools

(Taylor) #6

You almost had it. It’s actually just settings not themeSettings :slight_smile:

(Sarah) #7

Thank you @tshenry! I also had it in the wrong file.

My code was in /common/header.html instead of /common/head_tag.html

Thank you for your help! :slight_smile: