# Installation

## Installation Guide

Veltro uses `npm`, which comes with Node.js, and includes a `package-lock.json`. The Node.js version you need depends on your edition:

| Edition | Node.js version                                                                          |
| ------- | ---------------------------------------------------------------------------------------- |
| Astro   | 22.12.0 or later                                                                         |
| Tina    | 22 (22.23.4 or later) or 24. Tina's command line tool supports only those two versions   |
| Sanity  | 22.12.0 or later                                                                         |

<Aside type="tip">
  Use the scripts in `package.json`. The development and build scripts
  regenerate the settings file that Astro imports.
</Aside>

### Install Node.js

<Tabs>
  <TabItem label="Windows">

    Install Node.js from [nodejs.org](https://nodejs.org/en/download/), then verify it:

    ```bash
    node -v
    ```

  </TabItem>
  <TabItem label="macOS">

    Install Node.js with Homebrew or the official installer:

    ```bash
    brew install node
    node -v
    ```

    For the Tina edition, Homebrew may give you a newer version than 24, so use the official installer if it does.

  </TabItem>
  <TabItem label="Linux">

    Install Node.js with your preferred package manager or the official installer, then verify it:

    ```bash
    node -v
    ```

    Your package manager may give you an older version than the table above asks for. If it does, use the official installer.

  </TabItem>
</Tabs>

### Install Dependencies

Unzip the theme and open a terminal in its folder. In the Tina edition, that is the `themes/veltro-tina` folder inside the zip.

```bash
npm ci
```

This installs the exact dependency versions from `package-lock.json`.

### Start Development

```bash
npm run dev
```

Your site is at `http://localhost:4321`. What happens next depends on your edition:

- **Astro:** this generates the settings file from `src/config/config.toml`, watches that file for changes, and starts the site. Edit the files in your code editor.
- **Tina:** this does the same, and also starts the editor. Open `http://localhost:4321/admin/` and click **Enter Edit Mode**. You need no account and no password. See [Tina](../../features/tina/).
- **Sanity:** this does the same as the Astro edition, and the site runs with the bundled demo content, with no account. To edit it, run `npm run setup` to connect your own Sanity project, then `npm run dev:all`, and open the Studio at `http://localhost:3333`. See [Sanity](../../features/sanity/).

If another program uses port 4321:

- **Astro:** run `npm run dev -- --port 4322`.
- **Tina:** set `PORT`. `TINA_GRAPHQL_PORT` and `TINA_DATALAYER_PORT` move the editor's other two ports, 4001 and 9000.
- **Sanity:** set `SITE_PORT` in `.env`. `STUDIO_PORT` moves the Studio from 3333.

<Aside type="note">
  `npm run dev` starts the `config.toml` watcher and the site together. We have
  not tested it on Windows. If the site doesn't start there, press
  <kbd>Ctrl</kbd> + <kbd>C</kbd> and run the two parts in two terminals: `npm run toml:watch -- --watch`
  in the first, `npx astro dev` in the second.
</Aside>

### Check, Test, And Build

Run these one at a time:

```bash
npm run astro-check
npm test
npm run build
```

The production build regenerates the settings file, builds the static Astro site, removes draft pages from the sitemap, and writes the result to `dist/`. In the Sanity edition, it reads your published content, or the bundled demo content if no project is connected.

### Preview A Production Build

```bash
npm run preview
```

The preview script performs a fresh build before starting Astro Preview.

### Other Scripts

| Script                          | What it does                                                                                                                                                 |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `format`                        | Formats the files in `src/` with Prettier                                                                                                                    |
| `test:watch`                    | Runs the unit tests again when a file changes                                                                                                                |
| `generate-favicons`             | Makes the favicon files from your source image. See [Site Identity & Logo](../../customization/site-identify-logo/)                                          |
| `generate-multilingual-content` | Adds a language. It needs the language's details, and the flags differ by edition. See [Internationalization](../../customization/internationalization/)     |
| `remove-multilingual`           | Removes every language except your default one. See [Internationalization](../../customization/internationalization/) first                                 |
| `remove-draft-from-sitemap`     | Removes draft pages from the sitemap. `build` and `preview` run it for you                                                                                   |
| `deploy:cf`                     | Runs `wrangler pages deploy`. Wrangler isn't one of the theme's dependencies, so install and configure it first                                               |

### Scripts Only In The Tina Edition
| Script          | What it does                                                                               |
| --------------- | ------------------------------------------------------------------------------------------ |
| `tina:generate` | Rebuilds the editor's forms. Run it after you add a section, a field, or a language        |
| `tina:audit`    | Tells you if a save in the editor would lose anything. Run it after you edit files by hand |
| `setup:tina`    | Walks you through online editing with your own Tina Cloud project. It's optional           |

### Scripts Only In The Sanity Edition
| Script            | What it does                                                                                                                       |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `setup`           | Logs you in, creates your project, writes `.env`, and uploads the demo content                                                     |
| `dev:all`         | Starts the website and the Studio together                                                                                         |
| `studio`          | Starts the Studio on its own                                                                                                       |
| `import-seed`     | Uploads the demo content again. It replaces documents with the same IDs. Add `-- --missing` to keep the documents you already have |
| `sanity:validate` | Checks the Studio's schema                                                                                                         |
| `studio:build`    | Builds the Studio                                                                                                                  |
| `studio:deploy`   | Puts the Studio online                                                                                                             |
| `build:preview`   | Builds the preview server for draft preview online                                                                                 |
| `start:preview`   | Starts the preview server                                                                                                          |