How to deploy site from GitHub on Netlify
Connect your GitHub repo to Netlify via the dashboard (New site from Git → GitHub), authorize access, select the repo/branch, specify build command (e.g., <code>npm run build</code>), publish directory (e.g., <code>dist</code>), then trigger deploy. Netlify clones the repo, installs dependencies, runs the build, and publishes with automatic deploys on future Git pushes.
Prerequisites
- GitHub account with a public or private repository containing your site code
- Netlify account (free tier works for most users)
- Locally working build: run <code>npm run build</code> (or equivalent) successfully
- Committed lockfile like <code>package-lock.json</code> or <code>yarn.lock</code>
Step-by-Step Instructions
Log in to Netlify and add new site
Select GitHub as provider
Authorize Netlify on GitHub
Select your GitHub repository
Configure build and deploy settings
main or master; change if needed). Enter Build command like npm run build (leave blank for static sites). Set Publish directory to dist or build (use . for root). Add Environment variables if needed. Click "Deploy site" at the bottom.Wait for initial deploy
random-name.netlify.app. Once complete (green checkmark), visit the live URL.Customize site settings
my-site) for my-site.netlify.app.Verify continuous deployment
git push origin main). Netlify auto-detects, rebuilds, and deploys. Check Deploys page for logs, build times, and preview URLs for branches/PRs.Common Issues & Troubleshooting
Dependency install failures (e.g., <code>npm install</code> errors, <code>Cannot find module</code>, <code>ERESOLVE</code>)
Check deploy log for errors. Ensure lockfile (<code>package-lock.json</code>, <code>yarn.lock</code>) is committed and matches your package manager. Delete <code>node_modules</code> and reinstall locally, then push.
Build command fails (non-zero exit code)
Verify <code>npm run build</code> works locally. Check deploy log for stack traces. Add missing dependencies to <code>package.json</code> or set correct <strong>Node version</strong> in Netlify build settings.
Wrong publish directory (404 errors or blank page)
Confirm build output folder (<code>dist</code>, <code>build</code>) matches <strong>Publish directory</strong> setting. Run <code>ls -la</code> after local build to verify.
Deploy stuck or timeout
Check <strong>Deploys</strong> log for memory/timeout issues. Increase Node memory with env var <code>NODE_OPTIONS=--max_old_space_size=4096</code> or upgrade to larger build instance in Site settings.
Private repo access denied
Re-authorize Netlify in GitHub settings. Ensure repo permissions granted during OAuth. Try disconnecting/reconnecting Git provider in Netlify Site settings > Build & deploy.