Build for Production
Before deploying, create an optimized production build:dist/ directory:
The
dist/ directory contains all files needed for deployment. These are optimized, minified, and ready for production.Deployment Platforms
Choose a hosting platform based on your needs:Vercel
Zero-config deployment with automatic HTTPS and CDN
Netlify
Continuous deployment with forms and serverless functions
Cloudflare Pages
Global CDN with lightning-fast performance
GitHub Pages
Free hosting directly from your GitHub repository
Vercel
Continuous Deployment
Connect your Git repository for automatic deployments:- Push your code to GitHub, GitLab, or Bitbucket
- Import the repository in the Vercel dashboard
- Vercel automatically deploys on every push to main
Netlify
Git-based Deployment
- Push your code to a Git repository
- Log in to Netlify
- Click Add new site → Import an existing project
- Select your repository and configure:
- Build command:
npm run build - Publish directory:
dist
- Build command:
- Click Deploy site
Netlify provides automatic HTTPS, custom domains, and form handling out of the box.
Cloudflare Pages
Create Cloudflare Pages project
- Log in to Cloudflare dashboard
- Go to Pages → Create a project
- Connect your Git repository
Configure build settings
Set the following configuration:
- Framework preset: Astro
- Build command:
npm run build - Build output directory:
dist
Using Wrangler CLI
Deploy directly from the command line:GitHub Pages
Other Platforms
AWS S3 + CloudFront
DigitalOcean App Platform
- Create new app from your Git repository
- Configure build settings:
- Build command:
npm run build - Output directory:
dist
- Build command:
- Deploy
Firebase Hosting
firebase.json:
firebase.json
Environment Variables
If your landing page uses environment variables:Platform-specific Configuration
Vercel
Vercel
Add environment variables in project settings:
- Go to Settings → Environment Variables
- Add each variable with appropriate scope (Production, Preview, Development)
Netlify
Netlify
Add variables in site settings:
- Go to Site settings → Environment variables
- Click Add a variable and enter key-value pairs
Cloudflare Pages
Cloudflare Pages
Add via dashboard or Wrangler:
GitHub Actions
GitHub Actions
Use repository secrets:
- Go to Settings → Secrets and variables → Actions
- Add secrets and reference in workflow:
Custom Domains
All major platforms support custom domains:Configure DNS
Add DNS records for your domain:For Vercel/Netlify:
- A record pointing to their IP
- CNAME for www subdomain
- CNAME pointing to your Pages URL
Performance Optimization
Enable caching
Configure cache headers for static assets
Use CDN
Most platforms include global CDN by default
Compress assets
Enable Brotli/Gzip compression
Optimize images
Use Astro’s image optimization features
Deployment Checklist
Before deploying to production:- Run
npm run buildsuccessfully - Test with
npm run preview - Verify all environment variables are set
- Check that custom domain is configured
- Confirm HTTPS is enabled
- Test site on multiple devices and browsers
- Verify analytics and tracking codes work
- Check meta tags and SEO settings
Troubleshooting
404 errors after deployment
404 errors after deployment
Ensure your hosting platform serves
index.html for all routes. Add redirects if needed:Netlify: Already configured in netlify.toml aboveVercel: Create vercel.json:Assets not loading
Assets not loading
Check the
base option in astro.config.mjs matches your deployment path.Build fails on platform
Build fails on platform
- Verify Node.js version matches your local environment
- Check build logs for specific errors
- Ensure all dependencies are in
package.json(not devDependencies for build tools)
Environment variables not working
Environment variables not working
- Prefix public variables with
PUBLIC_ - Rebuild after changing environment variables
- Check platform-specific syntax for accessing variables
Next Steps
Your landing page is now live! Consider:- Setting up analytics and monitoring with your preferred service
- Configuring custom domains and SSL through your hosting platform
- Implementing performance optimizations for faster load times