Converting Blog Posts

I have a blog now running the Statamic CMS. It uses Markdown files for content and no database; so it’s similar in concept to Grav.

But its blog posts aren’t arranged the same way. Each post is in a file with a filename of the format 2013-03-05-1715-blog-post-title.md. The YAML head material looks like:

title: Blog Post Title
categories:
  - category1
tags:
  - tag1
  - tag2

Is there a handy way to convert the posts from Statamic format to Grav format?

Well your the first person to ask about a Statamic to Grav convertor so we don’t have anything in the toolbox yet to do this. However, both are markdown and both have ‘similar’ structure so it shouldn’t be that bad to convert.

The next question is how many posts do you have? If its not too many, it could well be easier and faster to convert them with a combination of manual (copy/paste) and automated search-and-replace.

the are two main things i see so far:

First the dates are hardcoded in the statamic filename, those would need to be added to the header:

date: 17:15 03/05/2013

or you could copy-paste directly (without conversion):

date: 2013-03-05-1715

Both will work fine.

Next, in Grav categories and tags are not hardcoded features like in Statamic, they are flexible taxonomies so you would need to add a taxonomy element like:

taxonomy:
  categories:
    - category1
  tags:
    - tag1
    - tag2

But that’s just a matter of adding the taxonomy element and indenting the rest. You will need to add categories and tags to the list of taxonomy types in the site.yaml. But that’s trivial:

taxonomies: [categories,tags,month]

It looks like that’s all that is required.

I would test this approach by copying over a couple of blog posts and attempting the manual conversion process I outlined above. That will give you a good idea of the amount of effort required in porting them.