Deploying a new site with Netlify is so simple it fits in a tweet:
npm install netlify-cli -g cd my-site-folder netlify deploy
This is all you need to deploy a static site folder, but Netlify can do much more for you.
For anything larger than a one page landing, you really should be using a static site generator or a front-end build tool like grunt or gulp.
If you’re using any of those, Netlify can make the process of collaborating and deploying much smoother.
Netlify lets you link a GitHub repository to a site. Each time you push to GitHub, Netlify runs a build with your tool of choice and deploys the result to our powerful CDN.
To start with the web UI, simply head to app.netlify.com and sign in.
To start by manually deploying a folder with a static site to Netlify, make sure you have
node js installed and then follow these steps:
npm install netlify-cli -g cd ~/my-static-website netlify deploy
If you are creating a new site on Netlify, or just moving a pre-existing site onto the platform, it’s good to keep the following things in mind:
NodeJS (including React)
If the static site generator you are using is built with NodeJS:
Make sure your
package.json contains the name of your tool. Do so by running the following command in your terminal:
$ npm install TOOLNAME --save
If your project directory has the same name as your tool, the above command will fail. So make sure your project name is something different.
You also need a
.nvmrc file at the root of your project to tell Netlify which version of NodeJS to use. In the terminal, enter this command:
$ node -v
To create a file to tell Netlify which version of Node.js to use, enter the following command in the terminal:
$ echo your.version.number > .nvmrc
The version of node you use is dynamically fetched using
nvm and then cached to speed up builds. If you don’t specify a version we default to using node 4.
If you are using a static site generator built with Ruby:
You need a Gemfile and a Gemfile.lock to tell Netlify which versions of your preferred tool to use. If there isn’t one, run the following command in the terminal:
$ bundle init
This will create a Gemfile in your project’s root directory. Open the Gemfile in your favorite text editor. Replace the following line:
# gem "ruby"
with this line:
Make sure you delete the #, then save.
Now run this command:
$ bundle install
This will install the jekyll gem and create a file called Gemfile.lock. This file will ensure that Netlify always uses the same version of of your tool that you used to build your site, thus avoiding any nasty surprises.
If your static site generator is built with Python:
It’s usually a good idea (but not necessary) to set up a virtual environment for Python projects. If you don’t know how to do so, follow these directions.
You want to make sure that Netlify knows exactly which versions of various Python plugins you are using. Do this by creating a file called
requirements.txt in your project’s root directory:
$ pip freeze > requirements.txt
This site is a great example of a project built on Netlify.
All of our documentation (this whole site in fact) is in a GitHub repository.
Whenever we push to GitHub or accept a pull request, Netlify will do a clean build of the site with Jekyll and deploy the result.