diff --git a/template.php b/template.php
index d121b3d..e846585 100644
--- a/template.php
+++ b/template.php
@@ -39,8 +39,10 @@ function tweme_preprocess_page(&$vars) {
   if ($page['header_bg']) {
     $children = element_children($page['header_bg']);
     $delta = reset($children);
-    $block = $page['header_bg'][$delta]['#block'];
-    if ($block->region == 'header_bg' && $block->module == 'imageblock' && module_exists('imageblock')) {
+    if (isset($page['header_bg'][$delta]['#block'])) {
+      $block = $page['header_bg'][$delta]['#block'];
+    }
+    if (!empty($block) && $block->region == 'header_bg' && $block->module == 'imageblock' && module_exists('imageblock')) {
       if ($img = imageblock_get_file($block->delta)) {
         $src = file_create_url($img->uri);
         $vars['header_attributes'] = sprintf(' style="background-image: url(%s)"', $src);
