FTP Deployments with Hexo

Automating deployments with Hexo

I think this might be the last big missing puzzle piece to this blog: easy deployments.

Hexo, being generally awesome, has a deploy command built into the CLI. You can get various plugins (as npm packages) for various kinds of deployments. I鈥檓 only really interested in FTP.

But I had run into issues using the deployment before. See, I have a couple of sites that are not part of the blog. They are standalone sites that live in folders under the site root. By default, the FTP plugin will blow away whatever is in the remote folder before deploying. This is less than ideal.

In the sample options, though, is an ignore property. Good luck finding documentation about it, there鈥檚 very little. In essence, the FTP plugin is a wrapper around ftpsync, a node FTP module. In the docs for that module is this nugget: ignore - the list of file patterns to ignore. Vague, but helpful.

I still couldn鈥檛 find many examples of using it, so armed with that little bit of help and a hunch that it was using globs, I tried to configure my own site. And it worked!

deploy:
    type: ftpsync
    host: 
    user: 
    pass: 
    remote: /public_html
    ignore:
        - .htaccess
        - /wedding
        - /lexitiles
        - /cgi-bin
    verbose: true

Now I can use hexo deploy --generate to generate and deploy the site in one go. The files and folders specified are left alone. Perfect!

Only one little weird issue remains: on Windows, that command doesn鈥檛 exit properly. It finishes just fine, but I have to use CTRL+C to get back to a normal command prompt. Ah, well.