Your site now has dynamic base URL configuration!
-
lib/config.ts- Central configuration file- Auto-detects environment (localhost, Netlify, production)
- Exports
siteConfigwith all site settings - Used throughout the app for consistency
-
.env.local- Your local environment variables- Currently set to:
https://notelyvoicepreview.netlify.app - Gitignored (not committed to repo)
- Easy to switch between environments
- Currently set to:
-
.env.local.example- Template for others- Shows all available environment variables
- Committed to repo for reference
-
BASE_URL_GUIDE.md- Complete documentation
- ✅
app/layout.tsx- UsessiteConfig.url - ✅
app/sitemap.ts- UsessiteConfig.url - ✅
app/robots.ts- UsessiteConfig.url - ✅
lib/seo.ts- Imports from config
# Edit .env.local
NEXT_PUBLIC_SITE_URL=http://localhost:3000
# Restart server
npm run dev# Edit .env.local (already set!)
NEXT_PUBLIC_SITE_URL=https://notelyvoicepreview.netlify.app
# Build
npm run build# Edit .env.local
NEXT_PUBLIC_SITE_URL=https://notelyvoice.com
# Build and deploy
npm run buildTo verify your current URL:
- Start dev server:
npm run dev - Open: http://localhost:3000/sitemap.xml
- You should see:
https://notelyvoicepreview.netlify.appin all URLs
To switch to localhost:
- Edit
.env.local: Change tohttp://localhost:3000 - Restart:
Ctrl+Cthennpm run dev - Check sitemap again - URLs should now show localhost
Before:
- All URLs hardcoded to
https://notelyvoice.com - Had to manually find/replace in multiple files
- Easy to miss files when switching environments
After:
- One place to change:
.env.local - All SEO features automatically use correct URL
- Auto-detection for deployment platforms
The base URL is now used in:
-
Sitemap (
/sitemap.xml)- All page URLs use correct domain
-
Robots.txt (
/robots.txt)- Sitemap URL is dynamic
-
Page Metadata (all pages)
- Canonical URLs
- Open Graph URLs
- Twitter Card data
-
Structured Data (JSON-LD schemas)
- Organization schema
- Website schema
- Software application schema
- Must restart dev server after changing
.env.local .env.localis gitignored - each developer sets their own- For Netlify production, set environment variable in dashboard
- Changes take effect immediately after restart
Your current setup:
- ✅ Preview URL configured:
https://notelyvoicepreview.netlify.app - ✅ Easy switching between environments
- ✅ All SEO features use correct URL
- ✅ Ready for localhost testing
- ✅ Ready for production deployment
Just edit .env.local when you need to switch environments!
Next Steps:
- Test locally: Change to
http://localhost:3000and verify - When ready for production: Change to
https://notelyvoice.com - Update Netlify environment variables for production deploy
Read BASE_URL_GUIDE.md for detailed instructions!