This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/source/_posts/2012-04-16-omega-subtheme-drush-omega-tools.md

43 lines
2.2 KiB
Markdown
Raw Normal View History

2015-03-16 21:18:03 +00:00
---
title: Create an Omega Subtheme with LESS CSS Preprocessor using Omega Tools and Drush
slug: create-omega-subtheme-less-css-preprocessor-using-omega-tools-and-drush
tags:
2015-06-14 02:27:41 +00:00
- drupal-7
- omega
- theming
- less
- drupal-planet
- drupal
2016-12-29 16:32:52 +00:00
use: [posts]
2015-03-16 21:18:03 +00:00
---
In this tutorial I'll be showing how to create an [Omega](http://drupal.org/project/omega) subtheme using the [Omega Tools](http://drupal.org/project/omega_tools) module, and have it working with the [LESS CSS preprocessor](http://lesscss.org).
2015-03-18 21:16:06 +00:00
The first thing that I need to do is download the Omega theme and the Omega Tools and [LESS](http://drupal.org/project/less "LESS module on drupal.org") modules, and then to enable both modules. I'm doing this using Drush, but you can of course do this via the admin interface at admin/modules.
2015-03-16 21:18:03 +00:00
2017-03-16 08:09:52 +00:00
```language-bash
$ drush dl less omega omega_tools;
$ drush en -y less omega_tools
```
2015-03-16 21:18:03 +00:00
With the Omega Tools module enabled I get the drush omega-subtheme command that creates my Omega subtheme programatically. Using this command, I'm creating a new subtheme, enabling it and setting it as the default theme on my site.
2017-03-16 08:09:52 +00:00
```language-bash
$ drush omega-subtheme "Oliver Davies" --machine_name="oliverdavies" --enable --set-default
```
2015-03-16 21:18:03 +00:00
By default, four stylesheets are created within the subtheme's css directory. The first thing that I'm going to do is rename `global.css` to `global.less`.
2017-03-16 08:09:52 +00:00
```language-bash
$ mv css/global.css css/global.less
```
2015-03-16 21:18:03 +00:00
Now I need to find all references to global.css within my oliverdavies.info file. I did this using `$ nano oliverdavies.info`, pressing `Ctrl+W` to search, then `Ctrl+R` to replace, entering `global.css` as the search phrase, and then `global.less` as the replacement text. After making any changes to oliverdavies.info, I need to clear Drupal's caches for the changes to be applied.
2017-03-16 08:09:52 +00:00
```language-bash
$ drush cc all
```
2015-03-16 21:18:03 +00:00
I tested my changes by making some quick additions to my global.less file and reloading the page.
2015-06-14 02:27:41 +00:00
If your changes aren't applied, then confirm that your global.less file is enabled within your theme's configuration. I did this by going to admin/appearance/settings/oliverdavies, clicking on the Toggle styles tab within *Layout configuration* and finding global.less at the bottom of *Enable optional stylesheets*.