Plone to WordPress migration

The task ahead was to migrate my old plone based blog/site to a wordpress site. Here was a short list of items to keep in mind:

  • plone import content (normal content ~ 600 entries, special:ContentPanels)
  • keep old links still valid including RSS !?
  • handle relative links in posts
  • handle google (sitemap, adwords, analytics)
  • design (find theme, modify css, logo/photo, php part)
  • others (the photos, favicon, 404 page, pre style for code snippets)

Export data

My first idea was to use the XML export of Plone but this seemed buggy in my install so I decided to create an XML export of my own.

I was able to export in this way all the items of type Document and their comments. I used the url of the page to generate categories. Tags cannot be imported this way so I will have to edit them at a later time.

There where 2 thinks I could not do using the tal language: (1) find and convert relative links to absolute ones and (2) generate the wordpress link. For this purpose the plone template refers to 2 external functions defined in the code bellow:

def fixRelative(text, base):
    exp = 'href="(?P<link>[^"]*)'
    p = re.compile(exp, re.IGNORECASE)
    base = base.replace('http://localhost:10000/len','http://www.len.ro')
    change = []
    for m in p.finditer(text):
        oldlink = m.group('link')
        newlink = urljoin(base, oldlink)
        if oldlink != newlink:
            change.append([oldlink, newlink])
    for ch in change:
        text = text.replace(ch[0], ch[1])
    return text.strip()
 
def newLinkKey(text):
    text = text.replace('.','')
    text = re.sub('[^A-Z0-9a-z]+', '-', text)
    text = text.lower()
    return text

Generate MT import format

After looking into the various import formats the simple text Moveable Type import format seemed best so I wrote an XSLT transformer:

<!--?xml version="1.0"?-->
 ]&gt;
 
TITLE:
 
AUTHOR:len
DATE:
 
STATUS:publish
 
CATEGORY:
 
-----BODY:
 
-----EXCERPT:
 
-----
 
COMMENT:AUTHOR:
 
EMAIL:
 
DATE:
 
-----
 
--------
 
<!-- 2008-10-07T15:54:17Z -->

I only had to do some small modifications to the date.

Generating redirect rules

It also became obvious that I have to write some kind of redirect mechanism in order keep the old links working. Using the same export file I wrote another XSLT transform to generate apache redirect rules:

<!--?xml version="1.0"?-->
 ]&gt;
 
        RedirectMatch (.*)/view$ http://ng.len.ro/$1
 
            RedirectPermanent 
 
             http://ng.len.ro/
 
        <!-- http://www.len.ro/photos/misc-stuff/ingrijorari -->
 
        <!-- 2008-10-07T15:54:17Z -->

I included the result file into the apache virtual domain definition.

Summarizing

  • plone import content (normal content, special:ContentPanels): automatic, I only had 10 ContentPanels which I migrated manually
  • keep old links still valid including RSS !?: ok via apache Redirect
  • handle relative links in posts: using a python parser of the content (accuracy?)

The rest of the topics are related to wordpress theme customization so they enter a different category

  • handle google (sitemap, adwords, analytics)
  • design (find theme, modify css, logo/photo, php part)
  • others (the photos, favicon, 404 page, pre style for code snippets)

23 Responses

  1. Congratulations, it is great that you have finally decided to move to wordpress – a very good CMS for blog. It seems to me that the theme still needs some adjustments, too.

  2. Thank you, I’ve forgot the: word-wrap: break-word; for IE.

  3. Now I’ve seen that you have to migrate the photo gallery too, or at least to redesign the template; it must resemble -at least in a way- with the main site/blog.
    More, it would be useful to active the e-mail notification, so that a visitor be notified on a new comment entry in a post he has already comented.
    Last but not least I personally lack a bigger version of the images uploaded in the gallery, a 1024 x 768 size would do nice. I remember you used to have this feature in the past ;).

  4. You are surely right, and I’m working on the photos template but enough fun for a weekend ;)

  5. Enough fun and a pleasant surprise for us, your readers :). Keep up the good work, as they say.

  6. Thank you :)

  7. thanks! this helped me a lot!

  8. I want to move my wpmu site onto a plone server… Is this possible at all?? after a bit pf research… I am not too positive.. but guess you guys are best equipped to answer it..

  9. Hello Sandesh, plone allows you for dynamic content creation using python scripts. I see no reason why this should not be possible. The only question is if the effort is worth it.

  10. Hi Len, could you provide a bit more details on how these steps could be implied? Multumesc!

  11. @hoppy I would gladly help you, do you have a specific question? What is your exact context?

  12. Ok, thanks – so, how the xml export could be customized? It has to be done through ZMI or else? Where do I have to put these four code snipplets?

  13. The xml export is actualy a .pt file. Just create an export.xml.pt file in your template location (for instance: /opt/Plone-2.5.3/zeocluster/Products/XTheme/skins/xtheme_templates/) with the content of this file and it should be accessible as site/export.xml after a restart of immediately in debug mode.

  14. Thanks, Len for this detailed description of Plone to WordPress migration – really useful since I’m migrating 1,000+ pages from Plone. Could never have done this without your post.

    A couple of points I have found as a non-Tech guy which may help others.

    1. If you want to break down process by folders

    add this line to portal_catalog search

    e.g. after review_state=[‘published’,’visible’],

    path=[‘/my_plone/subfolder’],

    2. In the XSLT transformer, in my version of Plone (2.5.2), if you want the date to be parsed correctly, creationdate must be lower case, i.e.

    rather than:

    3. When importing into WordPress 2.7 within the admin panel I found that .txt file needs to be saved as UTF-8 rather than default ANSI when viewing files using an editor like Notepad.

    4. The export code can be placed in any folder within ZMI as a page template file and then executed through “test” tab.

    5. The XSLT transformer can be run within a web browser by
    placing exported XML data in an XML extension file, e.g. original_source.xml which contains a line referencing the XLS stylesheet at top, i.e. first lines are:

    … Exported data.

    Hope that may help someone!

    Dave

  15. Sorry, it’s stripped the code I pasted.

  16. @dave I’m really glad this was of help to you.

  17. Len, I’m about to embark onto this endeavor. Does anyone here know if there is any impact if you’re wanting to use Thesis with WP? Thank you for sharing your knowledge. We could not do this without your post Len, many thanks.

    Cheers

  18. @troy, I don’t think there will be any problem since the import deals with the wp base. I don’t have first hand experience with Thesis so you will have to test on your own. I am glad this article was of use to you.

  19. […] article on how to migrate Plone content into WordPress via Movable Type […]

  20. […] for @kagesenshi) have deep technical expertise on the innerworkings of Plone, or Zope. There was one solution, but reading through it, I know it would be a PITA.So  I decided that the best solution would be […]

  21. Len,
    The XML export isn’t showing up for me, ive been working rapidly at exporting plone content into xml, haven’t had any luck. if you could shed some guidance, id greatly appreciate it.

  22. I am attempting to migrate a news blog from Plone to WordPress, so this article would be extremely helpful. But it looks like your first code snippet (XML?) is just missing from the article?

    Do you still have this code somewhere? I’d sure like to try this, rather than cutting and pasting my old article.

  23. @Terry sorry, tried to find it but with no luck. Anyway my code applied to a very very old plone version.

Leave a Reply

*