Blogger to Typo Migration 4

Posted by Ric Tue, 27 May 2008 22:38:00 GMT

I’d been meaning to move my blog away from Blogger for a while and host it myself, and then I graded my old blog’s url with Website Grader. This found a few things wrong with my blog site (some of which were down to the blogger template), and it also pointed me to this article on HubSpot about why you shouldn’t use blogspot (or any other hosted blogging provider for that matter). This pushed me over the edge and persuaded me to actually go ahead and move.

The Swirrl blog is on Typo, and I’m happy enough with how it works, so I decided I was going to use the same engine for my personal blog. However, I wanted to import all of my old Blogger articles into my spanking new Typo installation but there was no easy way to do this (in fact this was one of the issues that HubSpot have with Blogger).

As you can see, I managed it in the end, and with this article I hope to make the process easier for those who want to follow in my footsteps! (These instructions assume a basic familiarity with rails).

1. Sign in to your blogger account, and make a back up of your current template.

2. If you aren’t already, make sure you’re using the ‘classic’ template (you might need to ‘revert’).

3. Follow these instructions from the blogger help pages for how to backup your blog, but with a few alterations:

1. Additionally set ‘Enable float alignment’ to ‘No’.

2. Instead of the template they suggest, use this:

<posts>
  <Blogger>
    <post>
        <id><$BlogItemNumber$></id>
        <title><$BlogItemTitle$></title>
        <body><![CDATA[<$BlogItemBody$>]]></body>
        <postedon><$BlogItemDateTime$></postedon>
        <comments>
        <BlogItemComments>
            <comment>
                <body><![CDATA[<$BlogCommentBody$>]]></body>
                <postedon><$BlogCommentDateTime$></postedon>
                <author><$BlogCommentAuthor$></author>
            </comment>
        </BlogItemComments>
        </comments>
    </post>
  </Blogger>
</posts>

3. When you publish your blogger blog with the temporary template, save it with an .xml extension.

4. You should now have an xml file that looks a bit like this: (make sure it’s a clean xml file with no other rubbish at the top).

<posts>
  <post>
    <id>115566100691553998</id>
    <title>Hello</title>
    <body><![CDATA[Hello!  Rich here.  Welcome to the Rich Text blog.  In here you will find rants and musings mainly on computing and technology but other things may creep in too. Stay tuned.]]></body>
    <postedon>8/15/2006 05:53:00 PM</postedon>
    <comments>
    </comments>
  </post>
  <!-- other posts here... -->
</posts>

5. Download typo from the typosphere download page. Unpack it.

6. Go into the typo directory you’ve just created and make a database.yml configuration file.

7. Create the database structure with:

db:migrate

8. From your typo directory start a server with:

script/server

9. In a browser, go to your typo site’s admin section (e.g. http://localhost:3001/admin) and sign up.

10. Have a look in the database and make a note of the user id of the user you just created.

11. Download my blogger to typo converter script. (This is based on a script I found on Jonas Bengtsson’s blog, with a few tweaks – Thanks Jonas!).

12. Run that script. (run ruby blogger.rb -h for usage). For example, the following will import the contents of /Desktop/blogger_export.xml (excluding blogger labels), under auhor ‘Ric’ (id 1), using the environment settings in /Documents/typo-5.0.3/config/environment:

ruby blogger.rb -l --author Ric --authorid 1 --files ~/Desktop/blogger_export.xml --envpath ~/Documents/typo-5.0.3/config/environment

13. Log back into your typo blog’s admin section and sort out your layouts, and delete the default Typo posts.

Phew! That’s it. You should now have all of your blogger posts in your new Typo installation.

Please be careful and make sure you take backups of anything important – I make no guarantees about my script. It was hacked together quickly to do the job in hand. Happy migrating…

Trackbacks

Use the following link to trackback from your own site:
http://www.ricroberts.com/trackbacks?article_id=blogger-to-typo-migration&day=27&month=05&year=2008

Comments

Leave a comment

  1. Patrick about 1 month later:

    Wow, this makes my life a lot easierl thanks!

    Here are a couple of notes I noticed when using it:

    • Be sure to set the Timestamp Format setting (in Settings->Formatting) to the format that includes the date and time. Originally, I had just the time, and I got an error that said something like:
    /usr/lib/ruby/1.8/date.rb:1214:in `new_with_hash': 3 elements of civil date are necessary (ArgumentError)
            from /usr/lib/ruby/1.8/date.rb:1258:in `parse'
            from blogger.rb:83:in `convert_entries'
    
    • You can avoid publishing the xml version of your blog by using the preview button in Blogger’s template editor. It will pop open a new window, and you can view source, and trim away the cruft before and after the tags.
  2. Ric about 1 month later:

    Thanks for the feedback Patrick. Glad it came in useful.

  3. Oscar 5 months later:

    Sorry, I change the original template for your template and give me XML error. Can you help me?

  4. Ric 5 months later:

    Oscar: Maybe. If you tell me what the error is! :-)

Comments