Overview
This portfolio is built with Astro, which can be deployed to virtually any hosting platform that supports static sites or Node.js. This guide covers the most popular deployment options.Build Process
Local Build
Before deploying, test the production build locally:- Compiles TypeScript and Astro components
- Processes and optimizes CSS with Tailwind
- Minifies JavaScript using Terser
- Removes console logs and debugger statements
- Generates static HTML files
- Outputs to the
dist/directory
Build Configuration
The build is optimized inastro.config.mjs:
astro.config.mjs
- CSS minification with esbuild (fast)
- JavaScript minification with Terser (smaller output)
- Console logs removed in production
- Debugger statements removed
Preview Production Build
Test the production build before deploying:dist/.
The preview server runs at
http://localhost:4321 by default. Check that all features work correctly, especially:- Language switching
- Dark mode toggle
- Internal navigation
- Asset loading
Deploying to Vercel
Vercel is the recommended platform for this portfolio. It offers excellent performance, automatic HTTPS, and seamless deployments.Prerequisites
- GitHub, GitLab, or Bitbucket account
- Your portfolio code pushed to a repository
- Vercel account (free tier available)
Deployment Steps
Import project
- Go to vercel.com
- Click “Add New” → “Project”
- Import your Git repository
Configure build settings
Vercel auto-detects Astro projects. Verify these settings:
- Framework Preset: Astro
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
Deploy
Click “Deploy” and wait for the build to complete. Your site will be live at
your-project.vercel.app.Vercel Configuration
The project includes avercel.json configuration file:
vercel.json
cleanUrls: true
cleanUrls: true
Removes
.html extensions from URLs:/es/index.html→/es/- Improves SEO and user experience
trailingSlash: false
trailingSlash: false
URLs won’t have trailing slashes:
- ✅
/es - ❌
/es/
Cache-Control headers
Cache-Control headers
Aggressive caching for static assets:
max-age=31536000- Cache for 1 yearimmutable- File never changes (uses content hashing)- Applies to JS, CSS, JSON, HTML, XML files
Automatic Deployments
Vercel automatically deploys:- Production: Every push to
mainbranch - Preview: Every pull request
Deploying to Netlify
Netlify is another excellent option with a generous free tier.Deployment Steps
Connect repository
- Go to netlify.com
- Click “Add new site” → “Import an existing project”
- Connect your Git provider and select repository
Configure build
Set these build settings:
- Build command:
npm run build - Publish directory:
dist - Production branch:
main
Netlify Configuration
Createnetlify.toml in your project root:
netlify.toml
Deploying to Cloudflare Pages
Cloudflare Pages offers global CDN distribution and excellent performance.Connect Git repository
- Go to Cloudflare dashboard → Pages
- Click “Create a project” → “Connect to Git”
- Authorize and select repository
Configure build
Set these settings:
- Production branch:
main - Build command:
npm run build - Build output directory:
dist - Root directory:
/
Cloudflare Configuration
Create_headers file in public/ directory:
public/_headers
Other Deployment Options
GitHub Pages
- Setup
- Repository Settings
Add GitHub Actions workflow
.github/workflows/deploy.yml:.github/workflows/deploy.yml
Custom Server (VPS/Docker)
For self-hosting on a VPS:Performance Optimization
Enable Compression
Most platforms enable gzip/brotli automatically, but verify:- Vercel: Automatic
- Netlify: Automatic
- Cloudflare: Automatic (with even better compression)
- Custom server: Configure in nginx/Apache
CDN Configuration
Ensure static assets are served from CDN:- Use the
public/directory for images, fonts, etc. - Reference with absolute paths:
/favicon.svg - Enable long-term caching for hashed assets
Image Optimization
While this portfolio doesn’t have many images, for future additions:Environment Variables
If you need environment variables (for analytics, etc.):- Local Development
- Vercel
- Netlify
- Cloudflare
Create
.env file:.env
Monitoring
Performance Monitoring
Use these tools to monitor your deployed site:- Google PageSpeed Insights
- WebPageTest
- Lighthouse (built into Chrome DevTools)
Analytics
Consider adding privacy-friendly analytics:- Plausible - Privacy-focused
- Fathom - Simple and private
- Vercel Analytics - Built-in for Vercel
Troubleshooting
Build fails with 'Module not found'
Build fails with 'Module not found'
- Run
npm installlocally to ensure dependencies are correct - Check that all imports use correct paths
- Verify
package.jsonandpackage-lock.jsonare committed
404 errors on deployment
404 errors on deployment
- Verify build output directory is set to
dist - Check that routes follow Astro’s file-based routing
- Ensure
vercel.jsonor platform config is correct
Dark mode not persisting
Dark mode not persisting
- Check that localStorage is accessible
- Verify the theme toggle script runs before paint
- Some platforms may have CSP restrictions
Language switching doesn't work
Language switching doesn't work
- Verify i18n configuration in
astro.config.mjs - Check that all language page files exist
- Test URL structure matches expected pattern
Next Steps
Customization
Customize your deployed portfolio
Dark Mode
Fine-tune dark mode behavior