When I first started using Netlify to host my website, francoscarpa.com, I saw different methods to upload the static files that made it up. The first way was the classic drag and drop. I could move files to Netlify’s website and get a published website in seconds. It was my original approach.
Then, Netlify CLI reached my ears. I integrated Netlify with the terminal of my MacBook Pro. This way, I could use simple commands launched from my machine without relying on the Web service to publish the website. I thought this method could be my default one, but then version control entered the scene.
Since I started working for my actual company, I have been using both Git and Team Foundation Version Control as the version control systems. I already knew the importance of VCSs before then, but I never had the chance nor the reason to use them in real life before. Netlify’s integration with GitHub encouraged me to integrate version control in my projects, too.
I created a GitHub repository to hold all of my website’s source code, including the
package.json file, which is mandatory to let Netlify know which dependencies your project has. Then, I configured Netlify to link my website to that repository so that every time I push changes to GitHub, Netlify runs a build on that code and publish the resulting outcome on the fly. You need to specify which build command Netlify needs to run to start the compilation process. In my case, it’s
npx @11ty/eleventy since I use the Eleventy static site generator.
This modus operandi has two benefits:
- I make changes locally and push them to a remote repository, so I always have a backup copy of my project securely stored online.
- I don’t have to run a second command to compile the source code locally and publish it to Netlify since Netlify itself does the work for me.
Here you can see the latest deploys I made so far, while here and here, I show you the settings I use for the build process. I highly recommend you to configure Netlify to use continuous deployment since it’s a great way not only to speed up your workflow but also to have a backup copy of your precious source code.