How To Create A Sub Theme For Drupal 7

One of the quickest and safest way to customize a drupal theme is to go via subtheme route.

Safest? Because even if the base theme get updated in the future all your modifications will remain intact unless there was a major change put in place by the author.

Firstly, let's assume the base theme name is "base" and "sub" is your new subtheme. In your case, replace each name accordingly.

Here are some steps needed to create a subtheme in Drupal 7:

  1. Make a copy of the "base" theme folder and rename it to "sub".
  2. Delete most folders and files within it that you don't need as most will be inherited from the base theme. Typically you only need to keep "style.css" and "base.info"  files. Remember to keep the base and subtheme in the same folder.
  3. Rename "base.info" to "sub.info". To be on the safe side, use all alphanumerics only and not special characters to avoid unexpected results. One time, I used a hyphen ("-") to name this file, example "my-sub.info" only to make my new subtheme disappear from the Appearance dashboard. It took me quite a while to realize this was the cause of the problem - ergh! very frustrating.. angry
  4. Edit "sub.info" to relect the changes and insert a new row with this line: base theme = base
  5. Activate your new subtheme as default.

Also beware of your Drupal and browser's cache. A lot of times they can play a havoc by not showing your latest style changes in the active theme be it base or subtheme. If you're experiencing this kind of issue it's worth trying to empty the cache as it's usually the culprit. Sometimes you'll have to wait for some time to pass for the changes to appear.

That's basically there is to it.

From now on just use the subtheme to customize the look and feel of your Drupal site. This way whenever the base theme got upgraded hopefully there's no unwanted surprise on the horizon. Even if there is, it can be just minimal at most.

If you need a more detailed instructions, watch this video:

You have anything to share? Just leave us a note down here..

Further Reading

  1. Creating a Subtheme in Drupal 7
  2. HowTo: Drupal 7 Sub-Theme Creation, Step-by-Step