mardi 1 mai 2007
Exporting a DotClear v1 blog to static HTML files
Par Julien, mardi 1 mai 2007 à 19:22 :: Geeking
Planning the migration of this blog to a new location[1], I have implemented a quick Ruby script to extract the content to static HTML files. The script is relatively small and uses ERB for the pages templates (like Ruby on Rails).
You can download it from http://www.izforge.com/dotclear2static/, it's under a MIT-style license (hence take it, fix it, scratch it, trash it, upgrade it).
This Ruby script extracts the posts from a Dotclear v1.x blog MySQL database. This is useful when you want to migrate to another blogging system without going through the hassles of making an import. Indeed, the import from Dotclear to, say WordPress, is a boring task.
Requirements:
- A MySQL database.
- Ruby
- Ruby/MySQL from http://www.tmtm.org/en/ruby/mysql/
Making a successful export:
- Obtain a database backup of your live DotClear blog.
- Import the database backup into your MySQL database. I suggest that you perform the extraction from a local database rather than from the real one, but that's up to you in the end of the day

- Open 'dotclear2static.rb' and change the settings that are available under the license text. Make sure that you enter the right settings for MySQL!
- Run 'dotclear2static.rb' ... and tada! You've got your static files!
- Don't forget to copy the Dotclear images folder to the output directory.
Making the transition : it would be stupid to loose your pagerank! Remember that "cool URIs don't change". My advice is that you:
- move your new blog to a new URL (say http://newblog.info/)
- move the static files from the old blog to a subfolder of the new URL (say http://newblog.info/old)
- put 301 redirections from the old location to the new URL (ex: http://newblog.info/old).
301 redirections can be set from a '.htaccess' file for the Apache HTTPD server. Please consult Apache documentations if you don't know how to do that...
Tip: the static filenames are of the form 'postnumber-titleurl.html', hence: you can redirect
http://oldblog.info/index.php/year/month/day/<post>
to
http://newblog.info/old/<post>.html
I'll put my htaccess files the day I make the transition to the new blog.
Edit: of course you should use HTTP 301 for redirections, not 403 
Notes
[1] Who will be smart enough to guess the URL? 
2 commentaires :: aucun trackback :: 889 lectures



