Canvas Theme Template

:information_source: Summary Quick start your theme design with a prepared theme template.
:eyes: Audience New developers that want to get started building themes for Discourse. Experienced developers that want to use a ready-made template.
:hammer_and_wrench: Repository Manuel Kostka / Discourse / Canvas / Canvas Theme Template · GitLab
:question: Install Guide How to install a theme or theme component
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Canvas provides a flexible template that allows you to create custom themes with less coding. Easily adjust properties and configuration values to tailor a theme to your needs.

Example views


The base template retains default values and remains neutral in design.

Minimal adjustments that modify a few custom properties and define a highlight color:

A design that integrates the Topic Cards component and custom styles for banners:

An elaborate theme that includes a custom font and unique color schemes:

Usage


  1. Clone the Theme Template.

  2. Synchronize the theme with your Discourse instance using the discourse_theme gem.

  3. Go to the admin backend and manually adjust these theme component settings:
    Category Banners
    Plugin outlet → above-main-container
    Tag Banners
    Show below site header → uncheck
    Show above main container → check

  4. Edit scss/properties.scss to define values for custom properties

  5. Edit about.json to add assets, color schemes and more theme components

A closer look at the setup


The Canvas Theme template only extends the default theme skeleton with bundling a few theme components and adding some ready-made style files. The actual features are handled by a separate theme component Canvas Settings. This component serves two functions:

This split setup allows you to create a theme using the Canvas template, while still benefiting from ongoing fixes and updates provided through the component.

Example themes


You can review the code of the shared example views or install them as your starter theme from these repositories:


:tada: A huge thank you to Discourse for sponsoring the development of this project!

19 Likes

Those theme settings don’t show up when I tried to install the example themes. Is that expected behavior?

1 Like

The settings are on the theme component installed as Canvas Settings. It’s maybe a bit misleading that settings are always named Theme Settings on the ui, also on theme components.

2 Likes

Found them in Canvas Settings component, thx!

3 Likes

Thanks so much for working on this @nolo.

I took the Editor version for a spin locally, it mostly works very well, but I noticed some small issues.


On a default install, without changing any settings, the tag label in the Extra Banners component shows up in the wrong place:

The category banner is also shown in the same place, above the sidebar. Latest topics, Hot topics are correctly shown in the main column.


I’m guessing it’s not a goal of the theme to fully cover the admin UI, however, the light and dark Editor color palettes have the admin sidebar looking quite different. I am curious if it is possible to harmonize with the non-admin sidebar.

3 Likes

The theme is meant to show banners next to the sidebar, using the above-main-container outlet. The Extra-Banners component uses that outlet by default, but the two components for Category and Tag banners are by default rendered below the header. I wouldn’t want to fork these components, just to set a different default outlet… That’s why I put these instructions:

But if that’s easy to miss, maybe there’s a better way to put it? :thinking:

Yeah, that’s easy enough and seems a good approach for this theme. I just added a commit!

3 Likes

Ah yes, I see how we got here. We don’t necessarily want to change the defaults in the category/tag banners components, don’t want to fork them either. Tricky to fix, let’s leave it as is for now and see if others run into the same issue.

Admin sidebar change looks good already, thanks!

3 Likes

Could these instructions be elaborated a bit? Is it not possible to just install from the admin UI? Thx :pray:t4:

EDIT: I installed via the admin UI and it seems to be working except there doesn’t seem to be anywhere to edit scss now

EDIT: nevermind, I see that is probably expected and you’re showing to edit the theme files directly. I wonder if it could be on the roadmap for this to happen via the admin ui? Like, have a variables editor same as you have a settings editor

3 Likes

I don’t know what’s on the core roadmap, but one thing you could do right now is create a new theme component right on the admin UI:

And then declare custom properties on it’s CSS file. You could either look up properties on the Readme file. Or copy the contents of properties.scss from the theme repo.

2 Likes

How do I clone this to Gihub? Still a bit on the green side :wink:

You could import it through the UI:

However, if you want to be able to sync changes, I believe you’d need to pull to a local clone and then push from it. Something like this:

  1. Clone from GitLab
git clone "https://gitlab.com/manuelkostka/discourse/canvas/theme.git"
  1. Set push URL to your GitHub repo
git remote set-url --push origin "git@github.com:Username/Reponame.git"
  1. Then you can periodically fetch from GitLab and push to GitHub
git fetch -p origin
git push origin
2 Likes

I don’t see a plus on mobile on GitHub. May need to try the command lines when Home.

All I see in GitHub on dashboard is option to create a new repo but no claim ne option. I am on free account so not sure if that might have something to do with it.

I added a component that lets you define a few style variables and layout options right on the component ui:

It’s limited compared to declaring custom variables on the stylesheet. But it lets you tinker with a few different looks. Curious to hear if that works! :eyes:

1 Like