Tag archives for Blogger

Monday, December 4, 2006

How-to: Import posts and comments from Blogger Beta into WordPress

(And into ExpressionEngine and Movable Type, too!)

Update: If you're migrating to WordPress, you might want to check out a shiny new WordPress plugin before you get into all my manual tomfoolery. I haven't had a chance (or a need) to test it, but Import New Blogger looks fast and painless.

Update 2: Supposedly WordPress 2.2 and higher natively support importing from "new" Blogger. These instructions are likely now completely irrelevant for WordPress, but should still work just fine for migrating to MT or EE.
 

You know I'm a general, all-purpose fix it guy, right? As snarky and bitchy as I can be about my job, it really is a great fit for me. I genuinely like helping people. In that same vein, as I'm sure most of you have noticed, I've kind of positioned myself as "the answer guy" to a lot of people for just about anything blogging related.

One of the questions I'm asked most often is, "How do I get my Blogger Beta posts and comments into WordPress?"* Anyone who's tried this knows that the import script currently available with WP (even in the bleeding edge developer versions) doesn't support Blogger Beta.

There already exist several workarounds that will allow someone to do this very thing. Unfortunately none of them are ideal. They'll either not import comments, or they'll only import recent posts or they're far too complex for ordinary mortals. I've always thought there must be a better way. In the absence of a proper WP import script, here then is what I've come up with.** This method works for importing into WordPress, Movable Type and Expression Engine. It also works for WordPress.com users, but with a very big caveat in step five.

Step one: tweaking Blogger Beta's settings

Login to Blogger Beta and visit the Settings tab of the control panel for the blog from which you'll be importing. Select the Formatting page. Change the setting for Timestamp format to mm/dd/yyyy hh:mm:ss like you see in the first image below (all images are hyperlinked to larger versions).

Blogger Beta screencap

While still on the Formatting page, set both Convert line breaks and Enable float alignment to "No."

Blogger Beta screencap

Click the Save Settings button at the bottom of the page to proceed.

Now select the Comments page, and there change the setting for Comments timestamp format to mm/dd/yyyy hh:mm:ss, just as you did for the post timestamps.

Blogger Beta screencap

Click the Save Settings button to move on.

Select the Archiving page. Set Archive Frequency to Monthly.

Blogger Beta screencap

Click Save Settings.

Step two: your Blogger Beta template

Now select the Template tab.

If you are using a Beta-style template, visit the Edit HTML page and there click the link for Revert to Classic Template

Blogger Beta screencap

You'll be prompted to confirm this and advised that your Beta-style template will be saved.

Now you're ready to continue regardless of what style template you were using. (So classic-style template users should start paying attention again.)

If your classic-style template contains any customizations, make a backup of your template now. Do this by copying the template from the Edit HTML page and pasting it into Windows Notepad or some other similar plain text editor. I can't stress this part enough. We're going to do something irreversible to the template so a manual backup is the only way to preserve your changes. Blaming me for losing your blogroll because you didn't follow the steps will create a curse upon your family.

Once your backup is safely tucked away, kill the entire template (in the Blogger control panel, not in your backup [can't stress that enough]) and replace it with this:

<?php header("Content-type: text/plain"); ?><Blogger>TITLE: <$BlogItemTitle$>
AUTHOR: <$BlogItemAuthorNickname$>
DATE: <$BlogItemDateTime$>
STATUS: publish
-----
BODY:
<$BlogItemBody$>
<BlogItemCommentsEnabled><BlogItemComments>-----
COMMENT:
<?php $comment<$BlogCommentNumber$> = '<$BlogCommentAuthor$>';
$comment<$BlogCommentNumber$>_author_pre = explode('>', $comment<$BlogCommentNumber$>);
$comment<$BlogCommentNumber$>_author = explode('<', $comment<$BlogCommentNumber$>_author_pre[1]);
echo "AUTHOR: " . $comment<$BlogCommentNumber$>_author[0] . "\n";
$comment<$BlogCommentNumber$>_url_pre = explode('href="', $comment<$BlogCommentNumber$>);
$comment<$BlogCommentNumber$>_url = explode('" rel="', $comment<$BlogCommentNumber$>_url_pre[1]);
echo "URL: " . $comment<$BlogCommentNumber$>_url[0] . "\n"; ?>
DATE: <$BlogCommentDateTime$>
<$BlogCommentBody$>
</BlogItemComments></BlogItemCommentsEnabled>--------
</Blogger>

Before going farther, a few words about this template. It's essentially an ugly hack of Movable Type's import/export format. Possibly incomplete details on the format can be found here. I say "possibly incomplete" because I can't find any details about the STATUS: publish bit. Since I found that bit in the WordPress Codex, it's possible that field is not part of the official specification and thus may not be supported by the importers built into MT or EE.

And while we're on the subject of the STATUS: field, the other option is "draft." Draft is probably the preferred option, as it will allow you to edit imported entries as required before they become part of your new blog, but manually publishing every new draft could be a massive chore if you have many posts. Replace STATUS: publish with STATUS: draft (or remove that line completely) at your preference.

When you're ready, click Save Template Changes.

Now view your blog. You'll note that it's disgustingly fugly. If you care to try to read any of it, you'll probably also note that none of the PHP has been processed. If you view the source of your page, you'll see the PHP tags sitting there ignored.

Update: A user has reported difficulty with step six when using Internet Explorer. If you're still using IE, it's time to move up to a better browser. If you can't (or won't) use a different browser, you may have better luck on step six if you edit this template to remove <?php header("Content-type: text/plain"); ?> from the first line. I thought manually specifying the output content type would increase compatibility, but it just might be having the opposite effect.

Step three: download the blog

Visit each of your monthly archive pages. Since you don't have a list of clickable links, you'll have to type the addresses manually. The structure of the archive URLs are like so: http://yourblog.blogspot.com/2006_12_01_archive.html. For each month of your archives, you'll need to change month and year in the URL. This could be a little time consuming if your blog has been around for a while. It would be nice if Blogger had yearly archives, but we've got to roll with what we've got.

You'll need to save each of your archive pages to your computer. In Firefox, select Save page as… from the File menu. In Opera, select Save as…, also on the File menu. In Internet Explorer 6 and lower, Save as… is found on the File menu but in IE7, you'll find it on the Page menu. Whatever web browser you're using, be sure to save your page as "All files" if it's available, or "text files" if it's not. Replace the .html extension with .php.

Blogger Beta screencap

When you're all finished, you'll have one file for each month of your Blogger archives. Those files should be named like so:

2006_12_01_archive.php
2006_11_01_archive.php
2006_10_01_archive.php
2006_09_01_archive.php

…and so on.

And you're ready for the next step.

Step four: remove Blogger's mess

Open one of your new PHP files with a plain text editor like Windows Notepad.

You've got to get rid of that Blogger bar foolishness. Do this by removing the first four lines and part of the fifth. Everything before has got to go.

Blogger Beta screencap

Save the file. Repeat this process for each of your monthly archives.

Step five: upload to your webspace

Now you'll need to get your PHP files onto your webspace. Do this any way with which you are comfortable: FTP, cPanel upload, whatever. I'd recommend placing them right in the root of your webspace for short URLs, but it doesn't really matter where you place them because they won't need to stay there permanently.

For WordPress.com users only: all of the steps in this process are completely compatible with your service, except this one. But all is not lost. If you've got a pal who's willing to host your few files for a while, that's all you really need.

Step six: saving again

Load the URL for each of your uploaded files in your web browser. You'll see your output is dramatically different.

Blogger Beta screencap

Without the Blogger gobbledygook, and after PHP has specified text/plain and parsed comment author links into separate AUTHOR/URL fields (if Blogger had separate template tags for those, this would be a lot simpler) we've got a proper, well-formed mt-import file. Yee-haw.

Now to save them. For each file, select Save as… again from the File menu (or whatever the command is for your browser). Set the file type to text and give your files a txt extension. Since this time the content type is set properly, you likely won't need to change anything, but you'll still need to double check.

Blogger Beta screencap

Now you'll have a lovely set of well-formed mtimport files with names like these:

2006_12_01_archive.txt
2006_11_01_archive.txt
2006_10_01_archive.txt
2006_09_01_archive.txt

And now we're ready to move on.

Step seven: importing (finally!)

We're in the home stretch here. The actual import process is easy as pie.

For WordPress users: In your Dashboard, look for Import as one of the top level options. You'll see "Movable Type and Typepad" on the list. Click that link and the very simple MT import wizard will begin. If you need assistance with this bit, check out the very detailed documentation and examples in the Codex. (Note that WordPress.com and the current 2.1 development versions of WordPress have the importers as a subpanel of the Manage page.)

For ExpressionEngine users: Upload your set of text files to your webspace (EE doesn't upload as part of the import). In your Control Panel, visit Admin -> Utilities -> Import Utilities -> Movable Type Import Utility. I'm really not an EE guy, so if you need assistance, you should visit pMachine's EE forums or check out this page in the EE wiki.

For Movable Type: I don't even have an MT installation anymore, so I really don't know how to direct you. This page in Six Apart's MT documentation would probably be a great place to start.

Step eight: clean up your own mess

Nothing remains now but mop-up. Delete all the temporary files from both your webspace and your own hard drive, although you might want to keep those text files. They're a neat, human readable backup of your blog. Can't hurt to keep.

Put your Blogger template back the way it was. If you made a backup of your classic style template (and you did, right? 'cuz I stressed that… a lot), restore it now. If you were using the Beta style template, "upgrade" from classic back to the template you had before.

Adjust Blogger's settings on the Formatting, Comments and Archiving pages back to their original values, or to whatever other settings you might prefer.

If you elected to replace STATUS: publish with STATUS: draft, you'll still need to review, edit and publish each of your imported posts.

Step nine: drink beer

You're done!

 

*In case you were wondering, the question I'm asked more than any other is, "What happened to my gravatars?" (go back up)

**Now that I've put forth all this effort, would you care to wager how quickly WordPress will have an update for the built-in importer? (go back up)

Friday, February 17, 2006

No more Blogger for me

This particular post will be this blog's last using the Blogger engine. My new blog will be powered by Wordpress and will located right here. You will not need to update any bookmarks or links.

The migration process is not instantaneous so do not be surprised if you do not see what you expect within the next hour or so.

Note to RSS/Atom users: Although the location of my blog will not change, my site feed will. You will need to update your feed aggregator.

Saturday, February 11, 2006

Notes on hosting your own blog, part 4

So I was playing around with hotlink* protection today. I thought I was having some kind of problem with my web server's configuration because none of the protected files would load on my home computer. It turns out that hotlink protection uses HTTP referrers to determine if a request should be allowed, and my firewall blocks referrers by default.

This could be problematic. I want to use hotlink protection to keep other people from scamming my bandwidth, but it's not reasonable to expect all of my visitors to add custom rules to their firewall just for me.

*What is a hotlink? A hotlink is an object inserted on one site that is loaded from another site. For example, if someone inserts an image stored on my webspace into their own site, whenever their site is displayed the image loads from my site. Flickr and Photobucket are examples of sites that are designed specifically for hotlinking images. You upload your photo to Flickr's servers and then you use that photo somewhere else.

Removing the ability to do that kind of thing might sound mean, but bandwidth isn't free. Sharing my bandwidth with the world does not also share my bandwidth costs with the world.

Thursday, February 9, 2006

Notes on hosting your own blog, part 3

Apparently Blogger requires you to manually adjust your site feed settings when you switch to your own host. Because I didn't know anything about this, my site was trying to serve up the wrong feed.

The atom feed is now fixed. Apologies to anyone who has tried unsuccessfully to subscribe.

I'm going to blame Michael Douglas for this.

Notes on hosting your own blog, part 2

The Blogger photo upload tool is still available when you publish to your own web space, but it uploads to your web space, not to Blogger.

I'm perfectly comfortable uploading my own photos manually, but I want my profile picture on Blogger. I use two different pictures: one with a border that displays on my own pages and one without a border that displays on my profile and all comment pages.

In order to get the Blogger version of my picture on Blogger where I want it, I had to upload it under my test blog.

Bitches.

Tuesday, February 7, 2006

Notes on hosting your own blog, part 1

Blogger is a little bitch about hotlinking images. So when you host your own blog, you can forget about using that handy photo upload tool. You'll have to use your own hosting space or a service like Flickr. For the moment I'm choosing to host my own images. To get those new images to work, I had to dig through my archives and edit every post that used a photo uploaded to Blogger. Bitches.

Also, CPanel is not for the faint of heart.

Tuesday, June 28, 2005

Don't mind me

Did you see that Blogger now has photo uploading in the post editor? I don't currently have any pictures I want to share, but I really want to see how it works. So I thought I'd just post something random. I was going to delete this post, but I seem to remember something about Larry J having a thing for Michelle Pfeiffer.

Michelle Pfeiffer

So… yeah. Now I know how it works. It's a hell of a lot simpler than Hello, but it compressed my image. The uploaded version looks terrible compared to my original. Bummer. And for this they screwed up everyone's templates with that clear:both crap?

Sunday, April 10, 2005

Five things Blogger needs

1. More templates
Blogger has a fairly respectable selection. But it's not enough. Only when no one bothers to use their own dreadfully unreadable custom template should Blogger say they have enough.

2. A language filter for that "Next Blog" button
It's mostly kinda cool that Blogger is multi-language. A lot of people complain that the internet is too U.S.-centric, so it's nice to see that our friends in Taiwan aren't shuffled off to something like blogger.com.tw. But my fuzzy feelings of international goodwill do not change the fact that I cannot read Chinese. Or Thai, Arabic, Hindi, and German.

How difficult would it really be for Blogger to add a menu in each blog's settings? Something like "This blog is written in…" and then add a menu to the Blogger bar "search only in language…"

Sometimes the Next Blog button will lead me to a blog I'd love to read, but just can't. Like this one. She's a 17 year-old liberal bisexual Peruvian city girl whose blog title is "Sticky Nights with Beba Newmann and Company." And just look at that booty. I'd be reading that blog five times a day. Except that I CAN'T READ THAT BLOG.

Blogger is such a cock teaser, dangling that in front of me.

3. Spam blog controls
For a while now advertising types have been talking about blogs as a "guerilla marketing" tool. Yeah, that's great. For them. But I'd love to hit the Next Blog button and be reasonably assured that I won't be accosted with offers for cheap airfare to Sweden.

Some people might argue that free speech protections cover commercial speech as well. But Blogger's TOS prohibit using your blog commercially (although it does make exceptions for affiliate programs.)

Spam blogs are a blatant violation of Blogger's terms. And they're really annoying.

4. Stronger tutorials for new users
Ok, this one is reaching a little. But I'd really like it if other bloggers realized that punctuation is pretty much required if you want anyone to understand what you're writing, proper capitalization makes for faster, easier reading, and under no circumstances should anyone ever use yellow text on a white background or more than two colors of text in the body of a post.

This isn't really Blogger's fault, but I'd feel better about the issue if Blogger was making a stronger effort to prevent it.

5. More server capacity.
This is Google we're talking about here. I can search for "Siberian foot toad" and Google will sort 8,000,000,000 web pages in 0.21 seconds. Why am I still haunted by "The document contains no data" messages?

I am so getting tired of those mystery error messages. So if anybody's looking at a gift for me, I really want a domain. And a webhost. And several of these.

Monday, March 21, 2005

Blogger… Oy!

Ok, it's not really Blogger's fault.

I'm trying to make my own template from scratch. Between Firefox, IE, Opera, and Blogger, this is an irritatingly difficult task.

At least so far I have some very attractive lines.

Monday, February 28, 2005

Wow, what a handy feature

Blogger has this thing where you can post to your blog via e-mail. That sounds like a feature I'd use. I was planning on blogging about the Oscars with my PDA while sitting on the couch. I thought it'd be a good idea to test it out at least once before I start randomly hammering out messages, so I sent a test message on Saturday afternoon. That message posted to my blog on Sunday afternoon.

It took 22 and a half hours for my e-mailed post to appear. A delay like that kinda limits its usefulness. It's pretty uncommon that I'm away from a web browser that long anyway. But who knows, maybe someday I'll be on vacation and want to queue a gazillion outgoing e-mails to post en masse when I get home.