On the internet, I had found information on how to import blogger into Drupal 5, but not into Drupal 6. So this has prompted me to present the information for the community at large, here is how the code was adapted for Drupal 6, thanks in part too to a fellow developer I work with: Brush. On the web, I had found:


However, the steps are not entirely clear, and the update process as well as the required template file are different for Drupal 6.

Here is what you will need to know to export Blogger / blogspot into a format that Drupal can read.

First steps are to change the settings in Blogger:


under settings -> publishing put your ftp server information.

under formatting set the maximum number of items in the index page to 999 posts (if you have more than 999 posts on blogger, then this solution will not work for you).

For the rest of the settings use:

Date Header Format

Day, Month DD, YYYY

Timestamp Format



Universal (Unicode UTF-8)

Enable Float Alignment


Then click Settings -> archiving tab and set:

Archive Frequency

No Archive

Enable Post Pages


blank the other fields, unless required.


The template file you must use in Blogspot is:

  $nid = 1;

 $iid = '<$BlogItemNumber$>';



if (trim($node['title']) == "") $node['title'] = "title";


echo "INSERT INTO node (nid, vid, type, language, title, uid, status,
 created, changed, comment, promote, moderate, sticky, tnid, translate)
 VALUES(".$nid.", ".$nid.", 'story', '', '".addslashes($node['title'])."',
 1, 1, ".$node['date'].", ".$node['date'].", 2, 1, 0, 0, 0, 0);\n\n";

echo "INSERT INTO node_revisions (nid, vid, uid, title, body, teaser,
 log, timestamp, format)
 VALUES(".$nid.", ".$nid.", 1, '".addslashes($node['title'])."',
 '".addslashes($node['body'])."', '', 'Imported from Blogroll',
 ".$node['date'].", 1);\n\n";


echo "insert into comments (nid, subject, comment, hostname, timestamp, thread, name) values(".$nid.", 'comment', '".addslashes($comment['body'])."', '', '".$comment['date']."', '1/', '".addslashes($comment['author'])."');\n\n";


Where $nid is equal to your current maximum node_id. You can determine this by going to your Drupal domain, logging into phpMyAdmin, and running the following SQL query:

select MAX(nid) from node;

This will give you the correct starting NID for your export script.


Now you are ready to hit “publish” When this occurs, you will get a lot of files, but the only one you are interested in is the new index.html it generates. This index.html file is actually a php file, only it still has the extension .html. So, this part is not obvious, but you have to grab this index.html file and re-name it to index.php. If you open the file, you should see a very-very long listing of all your blog posts all together in this one index.html file, along with images and comments. Place it on your new server in some location, I put mine under drupal in a folder called “/blog”.

Now that you have this done, log into your new site using SSH, go to the folder in question (/blog) and type in the command:

php index.php > index.sql 

What this will do, is it will run the index.php file as PHP, and parse all this information into index.sql. After you have run this command, open the index.sql file in a text editor, and see if it has an error listed, or if it instead has a bunch of data.

In my case, the end of the PHP file had some </script> tag stuff in it, which I needed to remove. And the index.sql indicated the line number of this problem at the bottom of the index.php file.


If you got this far, you are nearly done! The last step is to then run phpMyAdmin from the new Drual site, click on “import” and then select the index.php file. It should add lots of data to your table -> nodes and node_revisions. Alternatively, you can import it via SSH by typing:

mysql -u username -p databasename < index.sql

The last step in Drupal 6 is to set the current index for the comments to the highest made comment number. To determine this, run the following mySql command from phpMyAdmin or the prompt:

select max (cid) from comments;

And then update the comments table node_comment_statistics.


Getting the teasers at this point is relatively easy, as they can contain exactly the same data as the body-field for the node’s themselves. Simply run the insert script again, but this time, change the destination to be for the teaser’s and voila, you now also have teaser texts.


Even though my comments were automatically inserted, I must admit that the original name of the person making the comment was lost in the translation process. For my purposes, this was non-essential, but I can easily imagine that this is not the case for someone else… to solve this, I would imagine that something went wrong in the way that blogspot listed its names on the export, to how drupal was expecting them on the import. If someone manages to fix this, please post a comment on this blog, and I’ll be sure to update this tutorial!


I hope this has been helpful to you,