I’m probably very late to the Invoke party, and if you are too, it’s worth a few minutes of your time to start taking advantage of Invoke for your Pelican administration.

The Old Way

Since I got back into blogging, I was getting sick of:

pelican content

Check everything looks good locally:

pelican --listen

Publish the site ready for upload to server:

pelican content -s publishconf.py

Send changes to server

rsync -avc --delete output/ myserver.com:/var/www/simonh.uk/html

The New Way

# pip3 install invoke

Open up tasks.py in the root of your site and check the config section:

CONFIG = {
    'settings_base': SETTINGS_FILE_BASE,
    'settings_publish': 'publishconf.py',
    # Output path. Can be absolute or relative to tasks.py. Default: 'output'
    'deploy_path': SETTINGS['OUTPUT_PATH'],
    # Remote server configuration
    'ssh_user': 'you',
    'ssh_host': 'yoursite.com',
    'ssh_port': '22',
    'ssh_path': '/var/www/yoursite/html',
    # Port for `serve`
    'port': 8000,
}

Be sure to check the ssh lines in particular. The ssh_path was not right for mine, probably from when I ran pelican-quickstart.

Once you start using invoke, you can simply type:

invoke reserve which builds, then serves.
invoke publish which builds using publishconf.py, then runs rsync to your server.

I’ll have to see if I can automate my Mercurial committing and pushing using invoke, next.

Here is the relevant section from the pelican documentation: invoke