Skip to main content

Deploying Documentation to Cloudflare Pages

This guide explains how to deploy the Infowebplus documentation to Cloudflare Pages from a GitLab repository.

Prerequisites

  • GitLab repository with the documentation code
  • Cloudflare account
  • Access to Cloudflare Pages

Step 1: Prepare Your Repository

Ensure your documentation is in the docs directory and has a package.json with build scripts.

Step 2: Connect GitLab to Cloudflare Pages

  1. Log in to Cloudflare Dashboard
  2. Navigate to PagesCreate a project
  3. Click Connect to Git
  4. Select GitLab and authorize Cloudflare
  5. Select your repository

Step 3: Configure Build Settings

Configure the following build settings:

  • Project name: infowebplus-docs (or your preferred name)
  • Production branch: main (or your default branch)
  • Build command: cd docs && npm install && npm run build
  • Build output directory: docs/build
  • Root directory: / (leave empty or set to root)

Environment Variables (if needed)

If your documentation needs environment variables:

  1. Go to SettingsEnvironment variables
  2. Add any required variables (e.g., GTAG_ID for analytics)

Step 4: Custom Domain Setup

Add Custom Domain

  1. Go to your project → Custom domains
  2. Click Set up a custom domain
  3. Enter docs.infowebplus.com
  4. Follow DNS configuration instructions

DNS Configuration

Add a CNAME record in your DNS provider:

Type: CNAME
Name: docs
Content: [your-project].pages.dev
TTL: Auto
Proxy: Enabled (orange cloud)

Step 5: Deploy

Cloudflare Pages will automatically:

  • Build your documentation on every push to the main branch
  • Deploy previews for pull requests
  • Update the production site automatically

Manual Deployment

You can also deploy manually using Wrangler CLI:

npm install -g wrangler
cd docs
npm run build
wrangler pages deploy build --project-name=infowebplus-docs

Build Configuration

GitLab CI/CD (Alternative)

You can also use GitLab CI/CD to build and deploy. Create .gitlab-ci.yml:

image: node:20

pages:
stage: deploy
script:
- cd docs
- npm install
- npm run build
artifacts:
paths:
- docs/build
only:
- main

Troubleshooting

Build Fails

  • Check Node.js version (requires Node 20+)
  • Verify all dependencies are in package.json
  • Check build logs in Cloudflare dashboard

Custom Domain Not Working

  • Verify DNS records are correct
  • Wait for DNS propagation (can take up to 24 hours)
  • Check SSL certificate status

Preview Deployments Not Working

  • Ensure GitLab integration is properly configured
  • Check branch protection settings
  • Verify webhook permissions

Next Steps