This wiki is no longer in use. Use the nanoc wiki on GitHub
instead. Not everything from this wiki was migrated to the new wiki because quite a bit was no longer relevant. The contents of the old wiki are nonetheless preserved here in case you need it.
Converting a WordPress blog to a nanoc site
There are three ways of converting a Wordpress-powered site to a nanoc one. These three converters only convert posts; templates, comments etc will not be converted. The convertors are in draft quality which means that they are hard to use and are not feature-complete. Use with caution!
See ticket #2 for a (rather outdated) way of converting a WordPress blog to nanoc. The conversion script has not been tested in a while and it may not work well.
See this piece of code. Save it to a file, and run it inside the nanoc site directory where you want to create the post items. Edit the database connection details in the call to
DBI.connect. Post item identifiers will have the format "/posts/year/month/slug".
The easiest way to migrate is by using Export feature of WordPress 3 (and I think there's a plugin for WP2).
* Go to your WP3 admin panel, find Export on the left menu and save the XML file with all your data.
* Then run
gem install wpxml_parser and download this ruby script.
The parser gem you installed can read data from wordpress xml file, and makes it easy to turn your blog into any format you like. The importer gist is an example of how you can create a nanoc blog using that parser gem. Before running the script, make sure you look over it and customize it to the way you want your blog to be imported.
* Change the XML_PATH to the name of the xml file you downloaded, and NANOC_PATH to the directory where you have your nanoc config file (the site should be created already).
* Look at
build_post_attributes method, since the stuff you see there is going to be your yaml metadata (e.g. categories become your tags).
build_post_identifier method is going to be the url.
If you want to use years, months, or other data from your blog to generate yaml data or identifier, check out the wpxml_parser readme on github to find out how to get all kinds of different pieces of data out of your xml file. It's very easy. Once you adjust the script to your liking, run it, and you should have all your blog posts extracted as nanoc items.