11 October 2007

Blogger custom domains

This blog is currently hosted at http://www.codesimple.net. This is a pity since the more succinct http://codesimple.net would be preferable. Unfortunately if I try and set the custom domain in Blogger to just "codesimple.net" it complains with a somewhat dubious "Another blog is already hosted at this address" message.

I think perhaps this is related to also having Google Apps active on this domain. Both services require you to point your DNS at ghs.google.com.

Also slightly odd is that Google do an HTTP redirect for any requests to http://codesimple.net to http://www.codesimple.net. I can't find any setting in Google Apps to control this "feature".

WordPress to Blogger

I recently decided to switch my blog from Wordpress to Blogger. Not because I think Blogger is better but because I wanted to avoid maintaining my own instance of Wordpress and Blogger would host my blog on my domain for free.

To copy the posts across I wrote a small Python script which takes a file of exported Wordpress posts and uses the Blogger Data API to upload them to Blogger.

If you want to do this yourself, you will need to:

  1. Download the script wptoblogger.py.
  2. Ensure you have Python 2.5, BeautifulSoup and Google's GData Python Client.
  3. Create your target Blogger blog and note its ID.
  4. Export your Wordpress blog to an XML file (I think this is only available in version 2 and above of Wordpress).
  5. Run wptoblogger:
    python wptoblogger.py -u your_blogger_username -b your_blog_id -a author_for_posts wordpress_xml_file
There are a few limitations though...
  1. It doesn't support multiple blog authors - all posts will be marked with the author_for_posts.
  2. A limitation with the Blogger API means that comment authors can't be set (they always appear as the blog author). As a workaround, I prefix each comment with a "Comment from..." line (see the existing comments on this blog).
  3. Blogger impose a limit on the number of posts you can create via the API in a certain time period. So if you have a lot of posts to transfer you may need to modify the script to post them in batches over a number of days.