Deutsche Startseite · English Homepage

STRAVID - Building software collectively.

Jekyll - One Command FTP Deploys

This website is built with Jekyll and hosted on HostEurope. In order to get rid of the manual FTP deploy routine I wrote a little Thor task for command line deploys. With the help of LFTP I now have the same convenient deploy experience to my web hoster as I have with Heroku and GitHub Pages.

I recently updated this website with a new look and a simpler structure. While doing that I got really annoyed with my deploy process. Since this website is not hosted on Heroku or GitHub Pages but rather on my private webspace at HostEurope, I have to use a FTP program to copy my files by hand. This really sucks.

After a little research I learned that my HostEurope plan doesn't include SSH access, what a bummer. But I googled a little more because having one command deploys is a really nice thing. It turned out that for my case there was no other option than FTP.

At this point LFTP comes to the rescue. It is a lightweight and fast FTP client which is run from the command line. This means the command line requirement is met, check. The second great thing about LFTP is its mirror functionality. What you basically do is the following:

  1. Tell LFTP the remote directory you want to copy.
  2. Tell LFTP the local target directory where to copy should be moved to.
  3. Tell LFTP to mirror the remote files to your local machine.
  4. Lean back and enjoy.

This sounds great, but it has one big gotcha. It is in the wrong order. I don't want to copy files from my webspace, I want my local static files, generated by Jekyll, copied to my webspace and not the other way around.

But thank god LFTP has the -R reverse flag. This flag allows you to turn the mirroring process around so your local files get copied to the remote webspace.

With this information I was able to create my own one command deploy task. You can view the relevant Ruby code in this gist file.

While this approach is not as fast as a simple git push deploy to GitHub pages, it is as convenient. Removing the need of opening an FTP program and copying the files by hand to the server improved my workflow immensely. The great thing about this method is that it works with all static files and every hosting you can access via FTP.

Personally it made my HostEurope webspace a lot more useful to me. I tended to neglect it because I was spoiled by the seamless deploy experience I have with Heroku and GitHub Pages.

If you are in a similar boat like me and have some sites you have to deploy via FTP, do yourself a favour and invest the time to write your own custom deploy task. It will make you a happier developer. And as we all know, happiness is trump.


You have questions, ideas or feedback? I like to hear from you and I'm looking forward to exhange thoughts. Please send an email to david@strauss.io and say “Hello”.

Random Page
Sitemap
Imprint
Privacy Policy