Last updated April 15, 2016. Created on December 14, 2007.
Edited by konordo, ashish_nirmohi, choster, Grigoreas. Log in to edit this page.

Situation:

Either you have installed or modified a theme that just breaks everything, or you've deleted the current theme without disabling it first.

Initial checks

  1. Try clearing or rebuilding your CSS/JS and theme caches
  2. Make sure you have installed the new theme in the correct location (e.g. /sites/all/themes for D5–7, /themes for D8
  3. Make sure the file ownership and permissions of the new theme files is correct (i.e. whichever user Drupal runs as, typically the same as the web server, can read and execute)
  4. Make sure you have installed any base theme that may be required
  5. Make sure you have installed any dependencies that may be required by the theme, such as jQuery libraries or contrib modules

If you see some content but no menus or navigation blocks

We can fix up the themes by going directly to the required pages.

  1. Log in to your Drupal site, i.e. http://example.com/?q=user
  2. Browse your themes page and select a theme you know to be working:
  3. Clear or rebuild your CSS/JS and theme caches

If the problem theme still appears, check that it has not been forced in your settings.php file.

If you see no content at all, only error messages or a totally blank screen and you cannot login anymore.

Method 1: Change the active theme with Drush

You can change your default theme with a drush command, for example

# for Drupal 6/7
drush vset theme_default garland
# for Drupal 8 (Drush 7+)
drush config-set system.theme default bartik

Then, clear or rebuild your CSS/JS and theme caches. If the problem theme still appears, check that it has not been forced in your settings.php file.

If drush fails with an error, it is likely you have other problems with the installation besides or in addition to the theme, such as an incompatible module.

Method 2: Change the active theme in the database

The default theme setting is stored in Drupal's database, and thus can be changed by manipulating the database from the command line or an administration overlay or client like PHPMyAdmin or MySQL Workbench for MySQL.

Always make a backup of your database before changing values in it directly, as it is possible to destroy data and render your site unrecoverable at the database level. You have been warned.

In Drupal 6 and 7, the setting is stored in the system table:

# activate a trusted theme
UPDATE system SET status=1 WHERE name = 'garland';
# change the default setting
UPDATE variable SET value='s:7:"garland"' WHERE name = 'theme_default';

# clear the cache tables
TRUNCATE cache;
TRUNCATE cache_bootstrap;
TRUNCATE cache_block;

Note that 's:7' refers to the length of the following string. Modify as needed. This is database surgery, tricky stuff.

If you are using per-user themes, and you've just messed it up for yourself as admin, try

UPDATE users SET theme='garland' WHERE uid = '1';

In Drupal 8, the setting is in the config table, and stored as a blob value for system.theme.

Method 3: Remove theme files

Remove the files of the bad theme and clear or rebuild the cache. After clearing the cache you should be able to log in again. The site will not look very pretty until you change to a working theme, but the menus should be navigable.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

sparkweb’s picture

One thing that can exacerbate the situation is the theme_registry value in the cache table. I my case I was working on a theme and had moved files, but this setting was holding on to the old location of files and not finding them. Also the variables row can have an effect as well. They can both be emptied fro the database manually rather than trying empty the cache from the Performance admin. These rows did not seem to be affected either that way or by running cron. Only when emptying them directly did the changes reflect immediately.

guysaban’s picture

I read this page: http://drupal.org/node/530780

Comment #24 shows a simple way to set the default theme and the admin theme from the command line / terminal window / SSH using drush.

List themes: drush pm-list --type=theme
List enabled themes : drush pm-list --type=theme --status=enabled
Set the default theme: drush vset theme_default
Set the admin theme: drush vset admin_theme

tigron’s picture

I know it's been quite some time since you posted this but I just wanted to say thanks for adding this in this post. I'm loving drush more and more everyday and at least pat myself on the back a little for installing it and getting familiar when others said they weren't ready for it. Thanks again I need that 2 sec fix.

Steel sharpens Steel !

aosiname’s picture

Confirmation that

UPDATE variable SET value='s:7:"garland"' WHERE name = 'theme_default';
TRUNCATE cache;

Then just had to disable the themes i had enabled then enable my original site theme and set as default

BordenR’s picture

It is really, really stupid that one has to go into MySQL to recover a corrupted or bad theme. Is there a bug or a feature request trying to change this in D6 or D7? Maybe have a theme override in settings.php or be able to have a fall-back if you rename the theme in sites/all/themes or something that doesn't require you backing up your entire database in case you make a mistake?

chuta’s picture

set it in your sites/default/settings.php:

$conf['theme_default'] = 'minelli';

devin1492’s picture

Rename your non-working theme folder. Copy a simple, working default theme folder to your all/themes folder next to your non-working them folder and give it the original name of your non-working theme. Delete the default theme's .info file and copy over the one from your non-working theme. Go to your site. Drupal should now launch the default theme copy in place of your non-working theme and give you enough functionality to set your theme to something other than your non-working theme in the theme admin panel.

skbando’s picture

thank you Devin, your solution worked for me. Now i know that before performing a major update, one should.. a) Put the site in maintenance mode; b) Take a full backup; c) Disable all non-core modules; d) Set your theme to Garland (this is what I didn't do. and got into trouble).

SKBando

snoopy77’s picture

"Low Tech" or KISS ... whatever; it WORKS. Good post, devin1492 :-)

drupalshrek’s picture

Brilliant! That sneaky trick saved me!

drupalshrek

fastidioso’s picture

thank you...it works :)

COBadger’s picture

Devin1492, this was a really helpful tip. Thanks!

lemon dexter’s picture

Thanks devin1492. Got me out of a mess and only thing that seemed to help.

I used a copy of the Bartik theme (using Drupal 7).

However I knew there wasn't much wrong with the theme that crashed the site (tried it on another), but it just wouldn't load on the one that crashed. Managed to log in and reset cache (and all the other tips) and everything, but no joy.

Anyway, I found (accidentally) that if I disabled the theme and then enabled it before setting it as default, something (presumably in the database) got fixed.

This latter, extra step may help some folks. . .

marcn1961’s picture

After making adjustments to the Bartik theme, the site shows up in a theme without background & without admin bar and there is no way to reach the admin settings
Tried to remove the adjusted theme and cleared the caches (update.php and clear.php) but doesn't give any result

Following notice comes up
Notice: Undefined index: highlighted in include() (regel 126 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_first in include() (regel 138 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_second in include() (regel 144 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/modules/system/page.tpl.php).
Notice: Undefined index: bartik_marc in drupal_theme_initialize() (regel 100 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Trying to get property of non-object in _drupal_theme_initialize() (regel 145 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Trying to get property of non-object in _theme_load_registry() (regel 334 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Undefined index: bartik_marc in theme_get_setting() (regel 1414 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).
Notice: Trying to get property of non-object in theme_get_setting() (regel 1461 van /Users/marcnoel/Documents/Websites PHP en docs/MAMPdocs/includes/theme.inc).

any idea how to get back to a working drupal?
using Drupal v7.17

stevelast’s picture

Thank you Devin1492, as a non-tech type I took my courage in both hands and tried your suggestion, saved the day for me.

Vote_Sizing_Steve’s picture

If either of your default/admin themes work, you can grab the blob from that record (admin_theme or theme_default) and paste it in the breaking value's blob.

johnnybgood115’s picture

I somehow got rid of the main contents block on a theme, and now absolutely no content is showing on any pages, including the admin pages. I'm trying to reset the theme using this method but I run into this mySQL error:

#1146 - Table 'webibek7_SMFDdr.system' doesn't exist

That table definitely exists!

Any ideas or does any one have another reset for my particular issue?

Thanks!

justindodge’s picture

Thanks for this!
I also had an instance where the admin theme was set to the same broken thing as the normal theme.

In that case you can add this query to your list:
UPDATE variable SET value='s:7:"garland"' WHERE name = 'admin_theme';

sadamafridi’s picture

It works.

Archerswebsite’s picture

When i installed the Omega theme with Ohm subtheme, i could not log in anymore.

Thanks.

mrfreshly’s picture

It's worth mentioning this command:

admin theme reset to bartik:

# for Drupal 8 (Drush 7+)
drush config-set system.theme admin bartik

default theme reset to bartik:

# for Drupal 8 (Drush 7+)
drush config-set system.theme default bartik

To go along with the default theme change in the original post...If you've screwed up your admin theme, changing the regular default theme won't get you back into your admin UI.

And don't forget to rebuild cache after changing the theme:

drush cache-rebuild
modulist’s picture

I think the documentation on this page should have two separate entries for resetting the main theme as well as for resetting the admin theme as follows

# for Drupal 8 (Drush 7+) reset the default theme
drush config-set system.theme default bartik
# for Drupal 8 (Drush 7+) reset the admin theme
drush config-set system.theme admin seven

modulist