Drupal Sub-themes (Not just for zen)

posted by Ishmael Sanchez on Feb 05, 2010

After reading a few posts in the Drupal forums I felt compelled to write this article to help people new to Drupal theming. Any Drupal theme can be a sub-theme and actually this is probably the preferred way of modifying a theme rather just modifying the HTML and CSS. The reason sub-theming is better is because a sub-theme will inherit the parent theme's resources. So instead of duplicating the theme files you can simply override the elements you don't want. So let's say you like a contributed theme but want to change the color scheme it's much easier (editing and maintaining) to use a sub-theme than create a one off theme.

Creating a sub-theme

  1. Name your sub-theme and create the theme folder
  2. Create an info file and define the base theme (base theme = contribtheme)
  3. Add at least one new stylesheet (This will have your overrides)
  4. Optional: Define new regions, override template files, set advanced theme settings

Something worth noting is that a sub-theme is dependent on the parent theme. So what does this mean? If you upload only your sub-theme to your /sites/all/themes folder without also adding the parent theme your sub-theme will appear broken once you enable it. This is because without the parent the base CSS, JS, and templates are absent so the only thing that is loaded is your override files.

Resources

Post new comment

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.

Ishmael Sanchez