PSD to Drupal Theme

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

The problem with creating a Drupal theme is—once you know how—it's relatively easy. Experienced themers spontaneously transform design files into complete Drupal themes without realizing all of the little steps their brain takes to achieve the final solution. In this series we'll remove the mystery and teach you the step-by-step strategies and techniques needed to create Drupal themes. If you're new to Web development, this series will expose you to a number of excellent, time-saving tools including grid frameworks and Sass. This series focuses exclusively on the process of converting a static design to a Drupal theme. Having a little bit of Drupal site building experience, and a little bit of Web experience (HTML and CSS) will be helpful but it's not required. Where relevant, lessons have links to additional videos on Drupalize.Me and off-site resources to enhance your understanding of Drupal theming.

In this series you will learn about:

  • the strategies themers use to quickly transform design files into Drupal themes
  • documenting your process so that none of your design decisions are abandoned in static design files
  • connecting Drupal to your design by targeting specific elements
  • which tools will save you time in building out your Drupal theme
  • CSS coding conventions that you can use now which will comply with Drupal 8 coding standards when it is released

Your instructor for this series, Emma Jane Westby, has been teaching people how to theme for years. Her first book, Front End Drupal, was consistently cited as the best book to learn Drupal 6 theming. This series brings the concepts she taught you in Front End Drupal up-to-date for Drupal 7 (and beyond).

Additional Resources

In addition to the lessons in this series, Emma has assembled an extensive FAQ on Drupal theming.

Tutorials in this course
Categories
Drupal 7
More information

Emma Jane Westby introduces the series. In this series, you'll learn how to transform a static design file into a whole Drupal theme. We'll work through three major steps.

  1. Develop a style guide based on the design patterns we see in our design files.
  2. Build out Drupal so that it has all of the elements we need in place.
  3. Work with theming files to decorate Drupal.

Additional Resources

In addition to the lessons in this series, Emma has assembled an extensive FAQ on Drupal theming.

More information

In this lesson we'll take a tour of the theme you'll be building. The design we'll be working with was created by Betty Bisenthal. It's a fairly simple design with three columns and a banner image. It has been used as a starting point for several years by many people who are learning to theme. In this lesson we'll take a look at:

  • the design we'll be working with
  • variations of this design created by other students
  • how Drupal was customized to accommodate our design
  • the Sass used to create the layout for the site

By the end of this lesson you'll be able to describe the shape of the design used throughout this series, and identify variants of the design.

Additional resources

Domicile theme

Nine Sixty base theme

KidActive site

Digitise the Dawn

Categories
Drupal 7
More information

In this lesson we're going to learn about the front end development strategy of theming by components. This strategy relies on being able to break a design into individual components. Elsewhere on the Web this technique has been described as “atomic design” or “interface pattern pairing”. No matter what you call it, developing a pattern library of components is going to make it a lot easier to convert your design to a theme. This is an overview lesson that explains the strategy we'll be using in future lessons. More specifically, we'll look at:

  • two popular pattern libraries
  • an overview of how pages are built by Drupal so they can be rendered in a browser

By the end of this lesson you'll be able to identify components from a static design file by referencing a pattern library.

Additional resources

Atomic Design

SMACSS (Scalable and Modular Architecture for CSS)

Balsamiq Mockups

More information

Over the last couple of years we've seen the rise of object oriented CSS. There's been a lot of work done by smart folks to categorize different types of rules that we use to style our sites. We're going to take advantage of this work and use it to create a style guide. This foundation piece will help us to map the elements in our static design to the elements that we will build, and theme, in Drupal.In this lesson we'll create a style guide from our design with:

  • Base rules
  • Layout rules
  • Component rules

By the end of this lesson you will be able to create a text-based style guide of your design which accurately describes your site according to base rules, layout rules, and component rules. You will be able to further supplement this style guide by adding relevant images which reference the exact component the style guide is describing.

Categories
Drupal 7
More information

In the previous lesson you created a text-based style guide. It's now time to extract the necessary assets from our static design for use in our theme. To complete this lesson you will need a design application capable of opening a .psd file. The video demonstrates Photoshop, but I typically use Gimp. Either is fine. And if you don't have a graphics program, you can watch the video, but simply download the assets which were extracted during the lesson. By the end of this lesson you will be able to identify page-level design assets which need to be extracted from a design file for your Drupal theme.

Additional resources

Gimp

Photoshop

Pixelmator

Categories
Drupal 7
More information

In this lesson we will convert the style guide into a series of stubs which we can view in a Web browser. The design was originally created using the templates from the 960gs. We'll use this same grid framework to ensure all of our margins are automatically adopted. Grid frameworks are excellent for rapid prototyping of designs. Ultimately many front end developers choose choose to write their own for the final theme; however, if you're just getting started try to stick with a grid framework to reduce the number of things that you need to fight with.

The original theme that was created for this design used the NineSixty base theme. There are some nifty features in this theme which are great for more complex designs; however, it is not responsive, and does not use Sass. To bring the lessons up-to-date we'll be using the 960-Compass Plugin to generate our stub files and give us some sample Sass output to work with.

By the end of this lesson you will be able to convert a style guide to a series of stub files in Sass (or CSS) using SMACSS conventions and a grid framework.

Additional resources

SMACSS (Scalable and Modular Architecture for CSS) 

960gs

960-Compass-Plugin

Intro to Sass and Compass

More information

In SMACSS there are both major and minor layout rules that need to be created. The major layout rules are often handled by a grid framework and are used to describe big areas on your site, such as your Drupal regions. The minor rules are used for the components (for example how a picture aligns next to a paragraph of text). In this lesson we'll start by review how Sass allows us to use semantic naming for our CSS layout classes. Then we'll adapt the sample Sass provided by the 960 Compass Plugin so that it uses the necessary structure for our design.

By the end of this lesson, you will be able to implement the layout rules from your style guide as a Sass file using the 960 Compass Plugin as a reference.

Additional resources

960gs

Domicile Theme

More information

The final step before we step back into Drupal is to create a checklist for all the things we need to implement in Drupal. Using our style guide as a starting point, we'll ensure that every design decision which has been made can be implemented in Drupal. Your checklist might also include notes about which modules should be used to build each of the components from within Drupal. Creating a checklist might seem like a trivial task, but it's really important that you know exactly what you're about to build so that you don't get overwhelmed once you step into Drupal. By the end of this lesson you should be able to create a document with all the instructions, and notes you will need to apply your style guide to a Drupal site.

More information

Technically a theme can be installed onto any Drupal site, but it never quite works this way in real life. In this lesson we'll create a playground so that we can try out our theme before deploying it to a live server. We'll start by installing Drupal and adding some “fake” content and menus with the devel generate module. For these tasks we'll use Drupal's default theme, Bartik. By the end of this lesson you will be able to install Drupal in an environment where a development version of the theme can be safely tested.

Additional resources

Devel module

Categories
Drupal 7
More information

One of the most time consuming things a content editor can be forced to do is resize images before creating their content. Fortunately we can get Drupal to do the resizing for us. It's not perfect—it's just a plain resize, but it's enough for most basic sites. By the end of this lesson, you will be able to configure Drupal to resize images to your specification when they are uploaded using the image field type.

More information

It's pretty typical for a site to have one or two pieces of content that need to be easily edited, but also aren't nodes. For example: text in the footer. There are a number of ways to create this content. We'll use blocks to create this content as this is the easiest way to place content into a specific region without additional helper module. By the end of this lesson you will be able to create custom blocks, and place them into specific regions within your Drupal theme.

More information

A base theme is someone's idea of a really great starting point. It might include the stub files for CSS overrides, template files which bring Drupal core's markup up-to-date with HTML5, useful theme overrides which create new template variables. In other words: a base theme can provide you with a lot of really great stuff! The first version of the Domicile Theme used the NineSixty base theme—just enough for a simple site, but not so much overhead that it was complicated to learn. This version of the theme doesn't use a base theme. That's because, thanks to Sass, we'll be able to get almost all of the power of the NineSixty base theme through a gem plug-in. In this lesson you will learn which folders are typically used to keep Drupal themes neat and tidy.

More information

A theme is comprised of a collection of related files. Our completed theme will have CSS and PHP (with HTML fragments). To ensure all of these files are loaded, we need to tell Drupal where to find them, by listing the files in the theme's .info file. To begin working with our theme's info file we'll start with the only values which are required: name, version of Drupal core this theme can be applied to. We'll also add a few recommended pieces of information: description of the theme, the template engine, and a screen shot for easier selection of the theme from the administrative area. By the end of this lesson, you will be able to create an info file for a theme, and explore the relevant drupal.org handbook pages for more information on refining your theme's info file.

More information

Our main focus for the Domicile theme is restyling Drupal's markup with CSS. Although it is tempting to put all of your CSS into a single file, things can quickly grow out of control. In our theme we'll break our CSS into smaller stub files to make the theme easier to maintain using the file naming conventions for Drupal 8.By the end of this lesson you will be able to incorporate CSS files into your theme via the theme's .info file.

Additional resources

CSS file organization

More information

Drupal uses a series of nested template files to build out the rendered HTML pages we see in our browser. The template file page.tpl.php holds markup between <body> and </body> tags. We talked about the nested nature of template files in Lesson 3: Theming by Component.

In this lesson we will:

  • create the file page.tpl.php
  • add the relevant markup, and CSS classes for our grid framework
  • insert relevant PHP variables so that Drupal can render each of its page components.

By the end of this lesson you will be able to create, or adapt, a page.tpl.php file to suit the conventions you identified in your style guide.

More information

Designs often have a few elements which don't need to be easily edited and can essentially be "hard wired" into the template files. In our design there are three or four images which fall into this category. In this lesson we'll edit the page.tpl.php file to insert our design assets from Lesson 5: Extract Design Assets. By the end of this lesson you will know which variables can be used in a template file to ensure the correct directory is always used for hard-coded image files.

Categories
Drupal 7
More information

It's always smart to do your development work in a local environment, but eventually you will need to upload your theme your server. In this lesson we'll upload our theme to our web server using Filezilla. By the end of this lesson you will know which folder your theme needs to be uploaded to, and at least one application suitable for uploading files.

Additional resources

Filezilla

Categories
Drupal 7
More information

Once your theme is uploaded you still need to enable it before it will be applied to your site. By the end of this lesson you will be able to enable new themes for your Drupal site.

More information

Once all of the elements are in place, it's time to get down to the real work of theming the components. In this lesson we will:

  • use our style guide and checklist to find each component
  • check to see if the style looks "right"
  • troubleshoot broken styles so that each component looks as good as the designer's original, static files

By the end of this lesson you will be able to identify elements on a rendered Drupal page which do not have the correct styles applied, determine the source of the problem, and alter the markup or styles to correct the output displayed in a browser.

More information

To go from design to theme we worked through three major steps: building a style guide; building out Drupal; and finally applying the style guide to Drupal. In this lesson we'll review each of the steps outlined in this learning series:

  • creating a style guide with base rules, layout rules, and component rules
  • extracting design assets
  • configuring Drupal
  • creating theme files
  • debugging components from within Drupal

By the end of this lesson you will be able to outline the process needed to transform a static design file into a functional Drupal theme.

Categories
Drupal 7
More information

This learning series covered just the tip of the theming iceberg. Hopefully you're now feeling motivated to learn even more about theming. In this lesson we will review some of the other topics you will want to explore next including: advanced theming techniques, using a base theme, such as Omega, layout modules. By the end of this lesson you will by able to identify which videos you should (or could) watch next to learn more about theming Drupal.

This course appears in the following guides:
Categories
Theming
Drupal 7, 8, 9, and 10