# Installation

## Installation Guide

**Skill level:** Beginner · **Time:** 10 minutes

You need **Node.js** (the program that runs the theme) and a **code editor** to open the files. If Node.js is not installed yet, download the LTS version from [nodejs.org](https://nodejs.org/), install it, then come back here.

These steps are the same in the three editions. What `npm run dev` starts differs, as shown below. See [Editions](../../features/editions/).

### Requirements
- **Node.js 22.12.0 or later** in the Astro and Sanity editions (declared in `package.json` under `engines`). The Tina edition needs **22.23.4 or later**, and stay on version 22 or 24, the two that Tina's tools support
- **npm**, which comes with Node.js. Consultiz ships a `package-lock.json`, so use npm
- No account for the Astro edition, or for editing on your own computer in the Tina edition. The Sanity edition needs a Sanity account only when you want to edit content
- A code editor. [VS Code](https://code.visualstudio.com/) is a good free choice; Consultiz recommends extensions for it in `.vscode/extensions.json`

Check your version in a terminal:

```bash
node -v
```

The result must be `v22.12.0` or higher.

### Run Consultiz On Your Computer
<Steps>

1. Unzip the download. Move the theme folder to wherever you keep your projects, then open it in your code editor. It is the folder that contains `package.json` and `README.md`.

2. Open a terminal **inside that folder**. In VS Code, use **Terminal → New Terminal**.

3. Install the dependencies (only needed once, and again after updates):

   ```bash
   npm ci
   ```

   `npm ci` installs the exact versions listed in `package-lock.json`. `npm install` works too.

4. Start the development server:

   ```bash
   npm run dev
   ```

5. Open the local address printed in the terminal, usually [http://localhost:4321/](http://localhost:4321/).

</Steps>

Leave the terminal running while you work. When you save a file, the browser updates on its own. Press <kbd>Ctrl</kbd> + <kbd>C</kbd> in the terminal to stop the server.

`npm run dev` generates the settings file `.astro/config.generated.json` from `src/config/config.toml`, watches the TOML file for changes, and starts the site. If the TOML has a syntax error, the terminal shows its line; fix it and save again.

### What `npm run dev` Does In Each Edition
| Edition | What it does                                                                                                             | Use another port                          |
| ------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------- |
| Astro   | Generates the settings file, watches it, and starts the site at `http://localhost:4321`                                  | `npm run dev -- --port 4322`              |
| Tina    | The same, and it also starts the editor at `http://localhost:4321/admin/`. No account needed                              | Set `PORT` in `.env`                      |
| Sanity  | The same as Astro, with the bundled sample content until you connect a project. Then it also watches your **Site settings** | Set `SITE_PORT` in `.env`                 |

In the Sanity edition, `npm run dev:all` starts the site and the Studio together, with the Studio at `http://localhost:3333`. To connect your own project, run `npm run setup` first. See [Sanity](../../features/sanity/) and [Tina](../../features/tina/).

### Build And Preview The Production Site
```bash
npm run build
npm run preview
```

`npm run build` writes the finished site to the `dist/` folder. `npm run preview` builds it again and serves it locally, so you can test it exactly as visitors will see it. Drafts are not built.

Until you set `site.baseUrl` in `config.toml`, or a `SITE_URL` environment variable, which overrides `baseUrl` for a build, the build ends with a yellow `[site]` warning: there is no sitemap, and canonical links, RSS feeds, and `llms.txt` point to the build host. That is expected on your computer; set the address before you deploy ([Quick Start](../quick-start/), step 1).

### Every Script, In Plain Words
| Command                                 | What it does                                                                                       |
| --------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `npm run dev`                           | Generates the settings file, watches it, and starts the local site with live reload                |
| `npm run build`                         | Builds the production site into `dist/` and removes drafts from the sitemap. Warns while `site.baseUrl` is empty |
| `npm run preview`                       | Builds, then serves the production site locally                                                    |
| `npm run astro-check`                   | Checks components and content files against their schemas. Run it after you edit content or code  |
| `npm run verify`                        | Runs everything the theme checks: config generation, `astro-check`, tests, formatting, the production build, and route and section checks |
| `npm run test`                          | Runs the theme's unit tests                                                                        |
| `npm run format`                        | Tidies the formatting of files in `src/`                                                           |
| `npm run format:check`                  | Reports files in `src/` that `npm run format` would change                                         |
| `npm run generate-favicons`             | Creates every favicon size from `[site.favicon] image` in `config.toml`                            |
| `npm run remove-multilingual`           | Deletes every language except the default one. Read [Internationalization](../../customization/internationalization/) first |
| `npm run generate-multilingual-content` | Adds a language, with copies of your default language to translate. Read [Internationalization](../../customization/internationalization/) before you use it |
| `npm run deploy:cf`                     | Uploads `dist/` to Cloudflare Pages. Needs Wrangler installed first (see [Deployment](../../deployment/)) |
| `npm run toml:watch`                    | Converts `config.toml` into `.astro/config.generated.json`. `dev` and `build` already run it      |

<Aside type="note" title="Formatting and npm run verify">
  `npm run verify` also checks formatting with Prettier. If it stops at the
  formatting step after you edited content, run `npm run format` (or
  `npx prettier --write path/to/file`) and run it again.
</Aside>

### Extra Scripts In The Tina And Sanity Editions
| Edition | Command                 | What it does                                                               |
| ------- | ----------------------- | -------------------------------------------------------------------------- |
| Tina    | `npm run tina:generate` | Rebuilds the editor's forms, after you add a section, field, or language   |
| Tina    | `npm run tina:audit`    | Tells you if a save in the editor would lose anything                      |
| Tina    | `npm run setup:tina`    | Walks through online editing with your own Tina Cloud project              |
| Sanity  | `npm run setup`         | Logs you in, creates or chooses a project, writes `.env`, and imports the sample content |
| Sanity  | `npm run dev:all`       | Starts the site and the Studio together                                    |
| Sanity  | `npm run studio`        | Starts only the Studio                                                     |
| Sanity  | `npm run import-seed`   | Uploads the sample content again, replacing those documents                |

Next: [Quick Start](../quick-start/), to make the site yours.