Wordpress To Wintersmith

After moving to the wintersmith from wordpress, I have two problem.

  1. need to redirect old url to new url
  2. re-import old comments to new url
  3. re-import old images

Redirect old URL to New URL

For redirect old url to new url , I need to update on my nginx config file. I need to list down all old url and then prepend /articles/ in from of the url.

Example :

/create-ios7-fonts to /articles/create-ios7-fonts

So, we need to add old url in old articles markdown file. Wintersmith can use metadata at the markdown file.

---
title: wordpress-to-wintersmith
author: saturngod
date: Fri, 13 Apr 2014 14:48:53 GMT
oldURL: /this-is-old-url 
tags : blog,node.js,wordpress
template: article.jade
---

For this one, you can use https://github.com/saturngod/wp-to-wintersmith . It will exports all the markdown articles with oldURL meta.

After that, we need to list for nginx config.

Create a file nginx.jade under the template folder.

nginx.jade like following

- var articles = _.chain(contents.articles._.directories).map(function(item) {
-   return item.index
- }).compact().filter(function(article) {
-   return article.metadata.ignored !== true
- }).sortBy(function(item) {
-   return -item.date
- }).value()

each article in articles
    if article.metadata.oldURL
        | location #{article.metadata.oldURL} {
        |   rewrite ^(.*)$ #{article.url} redirect;
        | } #{"\n"}

After that , create nginx.json under the contents folder.

nginx.json like following

{
    "template" : "nginx.jade",
    "filename" : "nginx.conf"
}

After that , run

wintersmith preview

And then go to the http://localhost:8080/nginx.conf you will receive the list of redirect link.

Put this text on your nginx config file.

If you are using apache , you can use like following for .htaccess

- var articles = _.chain(contents.articles._.directories).map(function(item) {
-   return item.index
- }).compact().filter(function(article) {
-   return article.metadata.ignored !== true
- }).sortBy(function(item) {
-   return -item.date
- }).value()

| RewriteEngine On
| RewriteBase / #{"\n"}
for article in articles
    if article.metadata.oldurl
        | Redirect 301 #{article.metadata.oldurl} #{article.url} #{"\n"}

create .htaccess file instead of nginx.conf.

Reimport comments

If you are using wordpress , you need to imports all the comments from wordpress to disqus. After importing is completed, you need to change url in disqus.

Go to disqus admin panel > discussions > Tools

disqus

And the click on the Start domain migrations wizard .

You don’t need to change the domain . Just append /articles/.

Example : http://www.currenturl.com will be http://www.currenturl/articles/

It will take around 12 hours to complete mirgration. After complete , you can put disqus comment in your current blog.

Reimport Images

You may have a problem for image. You should create wp-content folder under the contents . Put old uploads folder under wp-content to contents/wp-content .

I recommend to use cloudapp to use image for articles. Upload image to cloudapp and then use the direct image link. So, next time you don’t need to migrate if you are moving the blog.

comments powered byDisqus