Setup a Jekyll site on Netlify

To staging and then to production

Initial set up for deployment

When setting up a new Netlify deployment for a Jekyll site, use this as the "build command":

npm run deploy

This command is configured in the Jekyll project in package.json

Automatic push to production

By default, Netlfiy will have automatic deployment from your master branch enabled. That means you should be very careful when pushing changes to master on github because that will trigger deployment to your live site!

It is best to work on the staging branch first and have that set up as a Deploy Context in Netlfiy. See below:

Setup a staging branch

This will be used to deploy and preview changes on Netlify before pushing them to the master branch, which would automatically push them to the live site. Instead, you'll want to push changes first to the staging branch.

1) Create a git branch called staging

git branch staging

2) Checkout that branch, then push it to github

git checkout staging
git push -u origin staging

3) In your Netlify account > this site > Deploys > Deploy Settings > Deploy Context > Edit Settings... Select "Let me add individual branches" then add staging - Screenshot

4) Now, when you work on the staging branch and push to github, this will automatically deploy to Netlfiy. You can preview the staging site by using the branch name as a prefix--. For example:

https://staging--briancasel.netlify.com

Last updated