Migrating from Textpattern to Hugo

October 19, 2020

Over the last few weeks, I've been working to switch my Blog from Textpattern to Hugo, and migrating the content (mainly my posts) to Markdown.

Unfortunately, Textpattern does not provide any export in a convenient format - There are ways to export a DB dump as backup or plugins for exporting data, but nothing out of the box.

So I decided to dump my posts from the database myself and I'd like to show how.

Find connection params

If you're struggling to find the credentials to your Textpattern database like me, it's best to have a look in the configuration file, config.php:

$ cat textpattern/config.php
    $txpcfg['db'] = 'textpattern';
    $txpcfg['user'] = 'txpuser';
    $txpcfg['pass'] = '###';
    $txpcfg['host'] = 'localhost:3306';
    $txpcfg['table_prefix'] = '';
    $txpcfg['txpath'] = '/var/www/kleemans.ch/textpattern';
    $txpcfg['dbcharset'] = 'utf8';
    $txpcfg['siteurl'] = "https://kleemans.ch";
    define('PROTOCOL', 'https://');

Connect to MySQL database

After getting the connection parameters, we can connect to the database:

$ mysql --host=localhost --user=txpuser --password=###

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 500
Server version: 5.7.27-0ubuntu0.16.04.1 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

After this we tell MySQL which database we want to use...

use textpattern

... and we can have a look at the tables:

mysql> show tables;