Your Custom Drupal Theme Should Always Use a Base Theme

106 19
Making a custom Drupal theme? Don't start from scratch. Ever. Start with a Drupal base theme, and use this to build your own custom subtheme. You'll save weeks, maybe months, of work.

Find a Base Theme


Although any theme can technically be used as a base theme, the phrase "base theme" usually means a theme that is specially designed to be customized. You can save a lot of time by mastering one of these base themes.


You can view the popular base themes easily. Go to the Drupal.org theme listing, and make sure they're sorted by "Most Installed." The most popular themes are actually base themes.

For instance, in a typical Drupal irony, the most popular theme of all, Zen, looks absolutely horrible out of the box. Why would 90,000+ sites run such a broken-looking theme? Because they don't. They run subthemes based on Zen. But these subthemes need Zen to work.

Choose a Base Theme


Which base theme should you use? It depends on your project, your experience, and your preferences. Some themes are geared towards clicking and configuring as much as possible in the browser. Other themes assume that you're happiest in a text editor, massaging code.

Take some time to read through the descriptions for these popular base themes:

You'll also find links to subthemes based on these base themes, so you can see what's possible.

If these themes intimidate you, keep browsing the theme list. You can find "lighter" base themes.

Base Themes Can Help With "Responsive" Layout


However, one major advantage of these popular base themes is how they handle "responsive" layout. More and more people expect to browse your site on their tablets and cell phones. It takes a lot of work to get your site looking good at these wildly different sizes.

A good base theme can handle most of this tedium. A responsive layout automatically switches stylesheets and other configuration based on the device. You can resize your browser and watch it happen, tricking the theme into thinking you have a tablet or even a cell phone. Look, Mom! No horizontal scrollbars!

Think about responsive layout now, before you build. Otherwise, you'll just make more work for yourself later.

Generate Your Subtheme


Once you choose your base theme, you'll need to generate your subtheme. Each base theme handles this differently.

At its most basic, making a subtheme can be as simple as a few lines in an .info file. However, the popular, complex base themes usually require you to generate several carefully named files. Look for instructions on the base theme project page, or in the README.txt that comes with the base theme.

The best and quickest method is when the base theme provides a drush command to generate a subtheme. Make sure you check for this option.

Craft Your Subtheme


Now enable your new subtheme, and set it as the default theme. Edit your new CSS file(s), refresh the site, and behold your handiwork.

(If nothing changes, try clearing the caches with drush cc all. Still no change? You'll have to dig deeper into Drupal caching.)

Ready to make your own theme? Commence your Drupal theming journey with a stroll through the Drupal.org theming guide.

On the other hand, you can always reconsider your theming options.
Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.