Skip to content

How to Work on Documentation

This guide sets up a development environment for the freeCodeCamp documentation site. Work through it once, in order.

A fork is your own copy of the codebase. You need one to contribute.

  1. Open the fork page:

    Fork “freeCodeCamp/contribute”

  2. Check the details, then click Create fork.

  3. GitHub redirects you to your fork at https://github.com/YOUR_USER_NAME/contribute.

In this guide, origin means your fork and upstream means the main repository.

There are two ways to run the site. Both work.

Local MachineGitHub Codespaces
Where it runsDirectly on your machineOn a GitHub server
You installNode.js, pnpm, GitNothing
Machine neededAny machine that runs Node.jsThe default machine is enough
Works offlineYes, after setupNo
CostFreeA free monthly quota, then paid
PrerequisiteVersionNotes
GitlatestThe version bundled with your operating system is often outdated.
Node.js24.xThe “Active LTS” version.
pnpm10.x-

Check what you have:

Terminal window
node -v && pnpm -v

Recommended, but not required:

  1. Clone your fork, replacing YOUR_USER_NAME with your GitHub username:

    Terminal window
    git clone --depth=1 https://github.com/YOUR_USER_NAME/contribute.git
    cd contribute

    --depth=1 fetches only the most recent commit, which keeps the download small.

  2. Add a remote that points at the main repository, so that you can sync later:

    Terminal window
    git remote add upstream https://github.com/freeCodeCamp/contribute.git

    Run git remote -v to confirm. You should see origin on your fork and upstream on freeCodeCamp/contribute.

  3. Install the dependencies. This also sets up the Git hooks:

    Terminal window
    pnpm install
  4. Start the development server:

    Terminal window
    pnpm develop
  5. Open http://localhost:4321.

Before making any changes, it’s important to create a new branch for your work. This keeps your changes organized and separate from the main codebase.

  1. Create and switch to a new branch, replacing feature/your-feature-name with a descriptive name for your changes:

    Terminal window
    git checkout -b feature/your-feature-name
  2. Ensure you are on your new branch:

    Terminal window
    git branch

    You should see your new branch name with an asterisk (*) next to it, indicating it’s the active branch.

You can edit or add files in the src/content/docs directory available here. When your changes are merged, they will be made available automatically at the documentation site.

If you want to create a link targeting a different section of the contributing guidelines, follow this format:

[Link text](/target-file-name#target-section-heading-id)
// If the target section is within the same page, you can omit the file name
[Link text](#target-section-heading-id)

This is necessary to make these links work for the translated version of the document. Otherwise, they will redirect to the English version of the page regardless of the language.

The site is generated using Astro and served using Cloudflare Workers. Here’s how it works:

Key Architecture

  • All documentation content is stored in src/content/docs/ as MDX files
  • The sidebar navigation is configured in src/sidebar.ts
  • Site configuration is managed in astro.config.ts
  • The site is automatically built and deployed via Cloudflare Workers

The site is deployed on Cloudflare Workers. Please check the wrangler config for deployment details.

Handy Scripts for Local Development

CommandDescription
pnpm installInstall all dependencies
pnpm developStart the Astro development server (localhost:4321)
pnpm buildBuild the site for production
pnpm previewBuild and preview locally using Cloudflare Workers
pnpm testRun all tests
pnpm lintCheck formatting and linting
pnpm formatAuto-fix formatting and linting issues
pnpm check:astroRun Astro type checking
pnpm check:linksValidate internal and external links
npx vitest run tests/filename.test.tsRun a specific test file

After you’ve committed your changes, check here for how to open a Pull Request.