Skip to content
Independent notebook · software, testing, and open source No ads · no sponsored posts · no affiliate links
Soham Parekh software notebook

Deployment note / Static sites

Deploying to Netlify

A short deployment note for a static site: connect the repository, set the build command, and publish the output.

Platform Netlify

Build Gatsby

Setup lesson

A static site is a folder of files. Deployment is the process of turning that folder into an address people can visit. Netlify does that by watching a Git repository, running a build command, and publishing the folder the build produces.

Before you deploy

Run the production build on your own machine first. Gatsby writes the finished files to a folder called public. If the local build fails, the hosted build will fail in the same way, usually with less context. Fix it locally, then push the change.

terminal
gatsby build
gatsby serve

gatsby serve runs the production build locally so you can check the output before it becomes public.

Connect the repository

Create a site in the Netlify dashboard and choose the option to import an existing project from Git. Authorise the provider if this is the first time, then pick the repository. Netlify reads the project and suggests a build command and publish directory.

Set the build

For a Gatsby project, the build command is gatsby build and the publish directory is public. Confirm those values before the first deploy. A wrong publish directory produces a successful build and a broken site, which is the most confusing kind of failure.

Deploy and read the log

Start the deploy and watch the log. The log is the most useful debugging tool you have. It shows the command Netlify ran, the version of Node it used, and the first error that stopped the build. Read the first error before you read the last.

Add a custom domain

When the temporary address works, add the domain in the Netlify settings and follow the DNS instructions. HTTPS is provisioned after the domain resolves. Give DNS changes time before you assume something is broken.

Previews and rollbacks

Netlify keeps a record of each deploy. That gives you a rollback path and a preview address for changes that are not ready for the main site. Preview builds are useful for reviewing a redesign without touching production.

A short checklist

  • The local production build passes.
  • The build command and publish directory are correct.
  • Internal links and forms work on the deployed site.
  • Canonical addresses use the final domain.
  • The custom domain resolves and HTTPS is active.
Field note

A deploy is not the finish line. It is the first time your site meets a real visitor.

Reference shelf

Official deployment documentation and related reading.