This project is optimized for deployment on Cloudflare Pages. It includes the necessary adapter and configuration out of the box.
Prerequisites
- A Cloudflare account.
- Node.js v20+ installed locally.
- Wrangler CLI installed (
npm install -g wrangler).
Deployment Methods
You can deploy using GitHub integration (recommended) or via CLI.
Option 1: GitHub Integration
-
Push your code to GitHub
Ensure your project is in a GitHub repository.
-
Connect to Cloudflare Pages
Go to the Cloudflare Dashboard > Workers & Pages > Create Application > Pages > Connect to Git.
-
Select Repository
Choose your repository and branch.
-
Configure Build Settings
Use the following settings:
- Framework Preset: Astro
- Build command:
pnpm run build - Build output directory:
dist
⚠️Search IndexingThe
buildscript automatically runsastro build && pnpm run index:content, which generates the Fuse.js search index. Ensure this completes successfully or search will not work on the deployed site. -
Save and Deploy
Option 2: Wrangler CLI
You can also deploy directly from your terminal.
-
Login to Wrangler
Terminal npx wrangler login -
Build and Deploy
Run the deploy script defined in
package.json:Terminal pnpm run deployThis command executes:
astro build && pnpm run index:content && wrangler pages deploy dist.
Search Indexing
The project uses Fuse.js for search. This requires a build-time step to generate the content index.
The build script in package.json handles this automatically:
"scripts": { "build": "astro build && pnpm run index:content", "index:content": "node scripts/generate-search-index.mjs"}If search isn’t working on your deployed site, ensure that the indexing step ran successfully.
Troubleshooting
Deployment Fails
Check the build logs. Common issues include TypeScript errors or missing dependencies.
Search Not Working
If search returns no results, check if the public/search/ directory contains en.json and ru.json files. These are generated during build by pnpm run index:content.