Your submission was sent successfully! Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

Vanilla: theme wrapping

Tags: Design

This article is more than 8 years old.


If you’ve been following our Vanilla framework series of blog posts you’ll be aware of why we needed this new framework and have a little insight into how we’ve set about using it. With this post we’ll be delving a little further into how we include and customise the framework for our Ubuntu family of websites.

Let’s get started with how Vanilla fits into a site’s structure with an introduction to the concept of Vanilla theming.

Robin touched on how to use the framework in his recent post ‘Vanilla: Creating a modular Sass library’, to recap, in case you didn’t get that far, here’s how you get started.

In this example, we’ll start by installing Vanilla directly into your project. We’ll add the latest version of vanilla-framework to your project’s package.json as follows:

or, if you don’t have a package.json file go ahead and run the following:

Once you have Vanilla installed, your project will have a new folder called ‘node_modules’. An example of your code structure could be:

Some of our larger sites, such as www.ubuntu.com, are served using Django and we like to keep the folder structure as close to a standard setup as possible, therefore, all our static files are kept in a static folder.

To include Vanilla and all its essence (see what I did there?) you need to add the following to your site’s main scss file:

When you compile styles.scss it will include the framework into the compiled CSS. But what if I want to change the default colours? I hear you ask. Well, if you have a look in the vanilla-framework/scss/ folder you’ll see a file entitled _global-settings.scss, in this file you’ll discover the default theme settings such as brand colour and the maximum width of your site, this needs to be imported above the framework. However, if you are likely to use these styles on more than one site, you might want to consider building your own theme.

Building a theme

To take www.ubuntu.com as an example, where we are using ubuntu-vanilla-theme, the file structure looks like this:

Both the theme and framework are in nested folders called node_modules as Vanilla framework is a dependence of the theme. You’ll see in the ubuntu-vanilla-theme/scss folder there’s a file called _theme.scss, a theme specific _global-settings.scss file and a modules folder where any overrides of the vanilla-framework will live.

Here is an example of what _theme.scss could look like:

There’s a fair bit going on here but basically what we’re doing is pulling in our theme specific _global-settings.scss file with overrides and any new variables we may want to include, above the framework imports so any overrides we add will take effect. Now you can add new modules by creating files in /modules/, then add an @import and @include in your _theme.scss file.

You’ll also see that there is a build.scss file, this imports the theme file and includes the ubuntu-vanilla-theme mixin. We use Gulp as our build system to automate common tasks in the development of our websites. Coming up next in our Vanilla flavoured posts, Karl will be showing you how to build a theme.

Talk to us today

Interested in running Ubuntu in your organisation?

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Designing Canonical’s Figma libraries for performance and structure

How Canonical’s Design team rebuilt their Figma libraries, with practical guidelines on structure, performance, and maintenance processes.

Visual Testing: GitHub Actions Migration & Test Optimisation

What is Visual Testing? Visual testing analyses the visual appearance of a user interface. Snapshots of pages are taken to create a “baseline”, or the current...

Let’s talk open design

Why aren’t there more design contributions in open source? Help us find out!