# Netlify

Netlify is the preferred Nacelle deployment method. Netlify can deploy your Nacelle project quickly and efficiently.

To deploy large stores (more than 2,000 product pages and blog articles) we have partnered with Netlify to create Nacelle specific solutions which scale. Please see reach out to our developer happiness team to get started with a larger store deployment.

# Connect to GitHub

Push your local changes to your GitHub repo

git push origin master

Once pushed, log in to Netlify and create a new site using GitHub. Find your Nacelle repository in the repo list and select it. You will be greeted with some options for deployment.

# Build Settings

You can leave the owner and branch (master) as is.

In the build command field enter the following:

npm run generate

And in the publish directory field enter

dist

# Environment Variables

Click on "advanced settings" then click on the "new variable" button. Here you will enter 3 environment variables.

The first key variable_name is

NACELLE_SPACE_ID

The space id is also found in dashboard. The second key variable_name is:

NACELLE_GRAPHQL_TOKEN

The value can be copied from the "token" field for the Nacelle space. The last is:

BUILD_MODE

and the value must be universal

# Facebook & Google Anaytics Tracker Variables

Facebook and Google Analytics tracking are built into Nacelle for most ecommerce events. Add these environment variables to activate the trackers:

NACELLE_FB_ID
(the Pixel ID found in Facebook Event Manager)
NACELLE_GA_ID

# Deploy

When you are done click "Deploy" and watch your Nacelle store build itself, automatically. For DNS routing, please see Netlify's Documentation.

Maximum Warp, Mr. Sulu!

# Updating Data

You will most likely update data to your products and content after your storefront has been deployed. Netlify makes it easy to rebuild your Nacelle project after data is updated.

To manually create a new deployment simply log in to your Netlify account, select the Nacelle project you wish to update, and click "trigger deploy". Once completed, your Nacelle storefront will reflect the adjustments you made to products and content.

# Webhooks

If your store has less than 2,000 products and blog posts, we recommend using webhooks to update the information on your PWA. If your store has more than 2,000 then we will set up an automatic batch build plan for you.

When Netlify receives a webhook from Shopify or your CMS, it will automatically rebuild your storefront with the new data. To begin, please see Netlify's documentation on webhooks.

# Shopify Webhooks

To create Shopify webhooks which will notify Netlify of updates, log into your Shopify admin. Click on settings then click on notifications and scroll down to "Webhooks". You can create several webhooks which with your Netlify webhook URL. We recommend settings up webhooks for every collection option (create, update, delete).

You must also add webhooks for Product Create & Product Update, pointing to the following URL:

https://901fp44g20.execute-api.us-east-1.amazonaws.com/prod/event/{spaceID}/{token}/product-create

Please note: Currently, Shopify does not have content webhooks. If you use Shopify as your CMS then changes to pages, articles and blogs must be triggered manually.

# Contentful Webhooks

Contentful makes it easy to create and set up webhooks in their dashboard. For details please see the Contentful Webhook Documentation. We recommend creating webhooks for all of your content models.

# Sanity Webhooks

Sanity provides methods to set up webhooks from their dashboard or CLI. For details please see the Sanity Webhook Documentation.

# GitHub Webhooks

Last, if you followed the documentation above and used a GitHub repo to deploy to Netlify the new pushes to your production brand will automatically trigger a new deploy.