Prerequisites
Before you begin, ensure you have:- A GitHub account with your repository
- A Netlify account (sign up at netlify.com)
- Azure AI API token
- GitHub API token (optional, for repository data)
Initial Setup
Create Netlify Account
- Go to netlify.com
- Click “Sign up” and choose “Sign up with GitHub”
- Authorize Netlify to access your GitHub account
Import Your Repository
- From your Netlify dashboard, click “Add new site”
- Select “Import an existing project”
- Choose “Deploy with GitHub”
- Select your portfolio repository from the list
Configure Build Settings
Netlify should auto-detect your settings from
netlify.toml, but verify:- Build command:
npx convex deploy --cmd "npm run build" - Publish directory:
dist - Functions directory:
netlify/functions - Node version:
20
Environment Variables Configuration
Navigate to Environment Settings
In your Netlify site dashboard:
- Click on “Site settings”
- Navigate to “Environment variables” in the left sidebar
Netlify Configuration File
Yournetlify.toml file should be in the root of your repository:
netlify.toml
Configuration Breakdown
- build.command: Runs Convex deployment and Vite build
- build.publish: Output directory for built assets
- build.functions: Location of serverless functions
- redirects: SPA routing support - redirects all routes to index.html
- headers: CORS configuration for API requests
Local Testing
Test your site locally before deploying:The
netlify dev command automatically injects environment variables from your Netlify site, so you don’t need a .env file locally.Manual Deployment
You can also deploy manually using the Netlify CLI:Automatic Deployments
By default, Netlify automatically deploys when you push to your repository:- Production deploys: Triggered on push to
mainbranch - Deploy previews: Triggered on pull requests
- Branch deploys: Optional, can be configured for specific branches
Configure Deploy Contexts
- Go to Site settings > Build & deploy > Continuous deployment
- Under “Deploy contexts”, configure:
- Production branch:
main - Branch deploys: All branches or specific branches
- Deploy previews: Automatically build deploy previews for all pull requests
- Production branch:
Monitoring and Debugging
View Build Logs
- Go to Deploys in your site dashboard
- Click on any deployment to view detailed logs
- Look for errors in the build output
Function Logs
- Go to Functions in your site dashboard
- Click on a function (e.g.,
chat) - View real-time logs and invocation history
Common Build Issues
Build command failed
Build command failed
- Verify
netlify.tomlis in the root directory - Check that all dependencies are listed in
package.json - Ensure the build command works locally:
pnpm run build
Function errors
Function errors
- Check environment variables are configured correctly
- View function logs in Netlify dashboard
- Test functions locally using
netlify dev - Verify the function path:
netlify/functions/chat.ts
404 errors on routes
404 errors on routes
- Ensure the redirect rule is in
netlify.toml:
CORS errors
CORS errors
- Verify CORS headers in
netlify.toml - Check function CORS configuration in
netlify/functions/chat.ts - Test API endpoints using browser DevTools or Postman
Performance Optimization
Build Plugin Recommendations
- netlify-plugin-cache: Cache dependencies between builds
- @netlify/plugin-lighthouse: Run Lighthouse checks on every deploy
Asset Optimization
Vite automatically optimizes your assets during build:- JavaScript minification
- CSS minification
- Image optimization (for imported images)
- Code splitting
- Tree shaking
Your site is automatically deployed to Netlify’s global CDN for fast access worldwide.
Custom Domain
To add a custom domain:Configure DNS
Follow Netlify’s instructions to:
- Add DNS records at your domain registrar, OR
- Use Netlify DNS for easier management
Next Steps
Environment Variables
Detailed guide to all environment variables
Serverless Functions
Configure Netlify Functions