Cover image for The Easiest Way (I've found) to Deploy 11ty to Server

The Easiest Way (I've found) to Deploy 11ty to Server

Being the newb that I am, I first manually upload and re-upload my website content (yes, this website) to the server. It was obviously cumbersome. Any small changes made, go to the host's file manager, replace the files with the new ones. Ahhh!

Then I thought, this is ridiculous, let's do it properly with SFTP/SSH. Made sense. The classic way to upload files to a server, right? So, I downloaded Cyberduck, tried to establish the connection... and got error! Again... error! Checked the password, the port, host name, etc. Everything seemed fine. But for some reason, it wasn't working. I even changed the login credentials on the server and checked again, same thing. Really frustrating!

Frustrated!

At this point, I was ready to go back to the same old manual upload. But then decided to ask Gemini maybe it could offer a better solution... and man, it delivered! Enters 11ty deploy!

Here's how to do it in two simple steps:

(1) Add the deploy piece to "scripts" inside package.json (replace username, domain, and path with your server's):

"deploy": "npx @11ty/eleventy && rsync -avz --delete _site/ username@domain:path"

(2) Deploy the 11ty site using the following command:

npm run deploy

It then asks you for the password and voila! The website is deployed to the server!