Learn how to deploy your ListLog blog to Cloudflare Pages with custom domains, edge functions, and global CDN. Complete setup guide with performance optimization.
Cloudflare Pages works with both GitHub and GitLab repositories. Set up your ListLog repository first:
# Clone the official ListLog repository
git clone https://github.com/grouplist/listlog.git my-blog
cd my-blog
# Update remote to your repository
git remote set-url origin https://github.com/yourusername/my-blog.git
git push -u origin main
Update your listlog.config.json
for optimal Cloudflare Pages performance:
{
"site": {
"name": "My Cloudflare Blog",
"description": "Lightning-fast blog powered by ListLog and Cloudflare",
"url": "https://yourdomain.com",
"author": "Your Name",
"language": "en"
},
"build": {
"postsPerPage": 15,
"excerptLength": 200,
"generateSitemap": true,
"generate404": true,
"generateRobotsTxt": true
},
"rss": {
"enabled": true,
"maxItems": 50
},
"cloudflare": {
"enableEdgeFunctions": true,
"analytics": true,
"webVitals": true
},
"performance": {
"enableCompression": true,
"optimizeImages": true,
"preloadCriticalCSS": true
}
}
Create _headers
file for custom headers:
# _headers file for Cloudflare Pages
/*
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:
/assets/*
Cache-Control: public, max-age=31536000, immutable
/*.html
Cache-Control: public, max-age=0, must-revalidate
/feed.xml
Cache-Control: public, max-age=3600
/sitemap.xml
Cache-Control: public, max-age=86400
Create _redirects
file for URL management:
# _redirects file for Cloudflare Pages
# Redirect old URLs if migrating from another platform
/blog/* /:splat 301
/posts/* /:splat 301
# Redirect RSS feeds
/rss /feed.xml 301
/rss.xml /feed.xml 301
# Pretty URLs (handled by ListLog's structure)
# Cloudflare Pages automatically serves /folder/index.html for /folder/
Connect your repository to Cloudflare Pages:
Setting | Value | Description |
---|---|---|
Framework preset | None | ListLog is a custom static generator |
Build command | npm install && npm run build |
Install dependencies and build site |
Build output directory | dist |
Where ListLog generates static files |
Root directory | / | Repository root (default) |
Set environment variables for build customization:
NODE_VERSION
= 18
NPM_VERSION
= latest
ENABLE_ANALYTICS
= true
https://your-project.pages.dev
Connect your custom domain to Cloudflare Pages:
blog.yourdomain.com
)If your domain is not on Cloudflare, add these DNS records:
Type | Name | Content | Proxy Status |
---|---|---|---|
CNAME | blog | your-project.pages.dev | DNS only |
Cloudflare automatically provisions SSL certificates:
Enable advanced analytics for your blog:
Add serverless functionality to your static blog:
// functions/api/views.js - Track page views
export async function onRequest(context) {
const { request, env } = context;
const url = new URL(request.url);
const page = url.searchParams.get('page') || '/';
// Store view count in KV storage
const viewKey = `views:${page}`;
const currentViews = await env.VIEWS.get(viewKey) || '0';
const newViews = parseInt(currentViews) + 1;
await env.VIEWS.put(viewKey, newViews.toString());
return new Response(JSON.stringify({ views: newViews }), {
headers: { 'Content-Type': 'application/json' }
});
}
Automatically optimize images with Cloudflare Images:
Enable Cloudflare's performance features:
Create wrangler.toml
for advanced build settings:
[build]
command = "npm run build"
cwd = "."
watch_dir = "posts"
[build.environment_variables]
NODE_VERSION = "18"
ENABLE_CLOUDFLARE_ANALYTICS = "true"
[[build.upload.rules]]
type = "include"
globs = ["dist/**/*"]
[[build.upload.rules]]
type = "exclude"
globs = ["dist/**/*.map"]
Cloudflare Pages creates preview URLs for every branch:
Enhance security with Cloudflare's WAF:
// Page Rules for optimal caching
# Static assets (CSS, JS, images)
/assets/* — Cache Level: Cache Everything, Edge TTL: 1 month
# HTML pages
/*.html — Cache Level: Standard, Edge TTL: 4 hours
# RSS and Sitemap
/feed.xml — Cache Level: Standard, Edge TTL: 1 hour
/sitemap.xml — Cache Level: Standard, Edge TTL: 1 day
Track real visitor performance:
Built-in analytics without third-party scripts:
Automated performance testing:
# Add to your CI/CD pipeline
name: Performance Test
on: [push]
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
https://yourdomain.com
https://yourdomain.com/welcome/
configPath: './lighthouserc.json'
package.json
has the correct build scriptpackage.json
dist
directory exists after buildyour-project.pages.dev
dig
or nslookup
to verify DNSYour ListLog blog is now powered by Cloudflare's global network! Here's what to do next: