Deploy Nikola through FTP

Français   |   Source

Nikola is shiped with a simple deployment mechanism and the possibility to easily deploy with GitHub. However, I am currently hosting my personal pages on Free server; the service is free and great but with no possibility to use either SSH (and rsync) or Git. Therefore, the question of FTP deployment was raised for me.

The solution I adopted is LFTP that is a file transfer line-command software to manage your file transfers over a variety of protocols, including FTP.

First steps

The first steps are quite easy:

lftp
lftp :~> open ftp://user:password@ftp.server.com;

You can then perform a number of basic tasks, both locally (with commands preceeded by l) and remotely:

lftp user@ftp.server.com:/~> cd website
lftp user@ftp.server.com:/website~> pwd
user@ftp.server.com:/website
lftp user@ftp.server.com:/website~> lpwd
/home/user/localdir

The mirror command allows you to realise copy à la rsync, selecting only files that were modified:

lftp user@ftp.server.com:/website~> mirror --reverse
Total: 35 directories, 96 files, 0 symbolic links
Modifié : 5 files, 0 symbolic links
49669 octets transfered

Deployment with Nikola

Then, you just have to update conf.py and edit DEPLOY_COMMANDS:

DEPLOY_COMMANDS = {
    'default': [
        """lftp -c 'set ftp:list-options -a;
        open ftp://user:password@ftp.server.com;
        lcd ./output;
        cd ./website;
        mirror --reverse'""",
    ]
}

You can then use directly nikola deploy command!