🔶 Deploying on Cloudflare Pages
🔶 Deploying on Cloudflare Pages
Cloudflare Pages offers fast global CDN, automatic SSL, and excellent performance.
Step 1: Prepare Your Project
Ensure your project is ready:
- Static site or built framework output
- Code pushed to GitHub/GitLab
- Build command configured (if needed)
Step 2: Deploy to Cloudflare Pages
Via Cloudflare Dashboard
- Go to pages.cloudflare.com
- Sign up/login with your Cloudflare account
- Click “Create a project” → “Connect to Git”
- Authorize Cloudflare to access your Git provider
- Select your repository
- Configure build settings:
- Project name: Your project name
- Production branch:
mainormaster - Build command: e.g.,
npm run build - Build output directory: e.g.,
dist,build,public
- Click “Save and Deploy”
- Wait for deployment to complete
Via Wrangler CLI
# Install Wrangler
npm install wrangler --save-dev
# Login to Cloudflare
npx wrangler login
# Deploy your project
npx wrangler pages deploy ./dist --project-name=your-project
Step 3: Get Your Cloudflare Pages URL
After deployment, you’ll get a URL like:
your-project.pages.dev
You can find this in:
- Cloudflare Pages Dashboard → Your Project
Test it: Visit https://your-project.pages.dev to ensure it’s working.
Step 4: Configure Custom Domain (After PR Approval)
Once your PR is approved and DNS is configured:
- Go to Cloudflare Pages Dashboard
- Select your project
- Go to Custom domains
- Click “Set up a custom domain”
- Enter:
yourname.iths.online - Click “Continue”
- Cloudflare will automatically configure DNS
- SSL certificate is provisioned automatically
- Wait for activation (usually within minutes)
Step 5: Create Your Domain Configuration
Create a JSON file for your PR:
{
"subdomain": "yourname",
"type": "CNAME",
"value": "your-project.pages.dev",
"owner": {
"name": "Your Name",
"email": "your.email@example.com",
"github": "your-github-username"
},
"project": {
"name": "My Portfolio",
"description": "Personal portfolio with fast CDN",
"url": "https://github.com/username/repo"
}
}
🎯 Cloudflare Pages-Specific Tips
Environment Variables
- Go to Project Settings → Environment variables
- Add production variables
- Add preview variables (optional)
- Redeploy to apply changes
Build Configurations
For advanced setups, create wrangler.toml:
name = "your-project"
compatibility_date = "2024-01-01"
[build]
command = "npm run build"
cwd = ""
watch_dir = "src"
Functions (Serverless)
Create serverless functions in /functions directory:
project/
├── functions/
│ └── api/
│ └── hello.js
Example function:
export async function onRequest(context) {
return new Response("Hello World!");
}
Preview Deployments
- Every pull request gets a unique preview URL
- Great for testing before merging
- Automatically cleaned up after merge
⚠️ Common Issues
Issue: Build Fails
Solution:
- Check build logs in dashboard
- Verify build command is correct
- Ensure all dependencies are in package.json
- Test build locally first
Issue: Custom Domain Not Activating
Solution:
- Verify domain is added in Cloudflare dashboard
- Check DNS propagation
- Clear browser cache
- Wait up to 24 hours
Issue: Functions Not Working
Solution:
- Ensure functions are in correct directory
- Check function syntax
- Review function logs in dashboard
✅ Checklist Before Submitting PR
- Project deployed successfully on Cloudflare Pages
- Pages URL is accessible (
your-project.pages.dev) - Website loads without errors
- All assets load correctly
- No console errors
- Responsive design works
- Content is appropriate
📚 Additional Resources
Ready to submit? Follow the Getting Started Guide to create your PR!