Web Design

Panels vs. Blocks

This argument keeps coming up: whether to use Panels or Blocks for laying out your content on a Drupal site.  Usually there is more than one right way to do things on Drupal, and this is no exception.  There are pros and cons, of course, but generally it seems to be more an issue of personal preference.

Background: both Panels and Blocks help you arrange areas of content on a web page.  Blocks is a built in feature and Panels is a community-contributed module.  Panels is much fancier, so the assumption has always been that it would be slower (because it takes more computing resources).

 

Performance

Mark Ferree recently pointed me in the direction of blog post from a couple months ago that does actual benchmarking of Panels vs. Blocks.  The result: Panels is faster if you have decent hardware.  Much faster if you turning on caching.

That, of course, touches on the bigger picture: there are lots of ways of improving Drupal performance.  If you're that concerned about performance, you should be using some combination of Boost, Varnish, APC, a real CDN (like Cloudfront), and a more powerful web host (like Pantheon).  A performant site on Pantheon will always perform better than a site running off a four year old laptop.

 

Workflow

I've got another reason why I prefer Panels: it has a much better workflow.  Here's a comparison of what it takes to achieve the same results with Blocks and Panels:

Blocks Panels
  • Create theme template with regions

  • Update theme.info file

  • Create multiple templates for multiple content types

  • Create a Panels Page

If you want different layouts in different parts of the site (eg. different content types), it gets worse:

Blocks Panels
  • Context, Display Suite, or multiple duplicate blocks with different visibility rules
  • Create a variant

Heaven help you if you want to switch themes at any point.  Add in nifty features like Panelizer or the In-Place Editor, and Panels is not just easier, but more powerful too.  Here's a full rundown of the pros and cons:

  Blocks Panels
Pros
  • Easier to do responsive theming
  • Built in
  • More powerful
  • More performant
  • Theme-independent
  • Easier to use
Cons
  • Layout tied to individual themes
  • Requires handmade theme templates
  • Not as friendly to responsive design

There are exceptions, of course.  Panopoly is 100% panels-based and has some excellent responsive layouts.  But those were custom made for the project.

 

The Pudding

. . . is where the proof is.  So they say.  On this site, I use both.  The general layout is done with blocks.  This is a completely custom theme made with SASS, so it was actually quite easy to create layout; I didn't need to customize the templates at all.  (I did anyway, but for other reasons.)  My portfolio, on the other hand, is a series of panels pages: one for the overview and a panelized page for each site in my gallery.  So, what's the rule here?

 

It Depends

I hate saying that, but it's true.  You can use Blocks 100% of the time or Panels 100% of the time, but you will find that one technique is better suited to one task and one technique is better suited to others.  Here are some general rules which might help:

  Blocks Panels
When It's Better
  • You're building a custom theme anyway
  • You don't mind your layout being theme-specific
  • Responsive design
  • Specific layout requirements for specific pages / areas / content types
  • You're not creating a custom theme
  • Want your layout to be theme-independent

Bottom line: I still prefer Panels, generally speaking.  It's newer, fancier, more powerful, easier, and more compatible.  But I'm not going to be religious about it; sometimes Blocks is a better fit.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

clever girl