# Installation

## Installation Guide

**Files:** `package.json`, `package-lock.json` · **Skill level:** Beginner

Follow these steps to set up and start using the theme.

### **Prerequisites**

Before you begin, ensure your system meets the following requirements.

<Aside type="tip">
  If you're on **macOS**, the easiest way to install dependencies is using
  [Homebrew](https://docs.brew.sh/Installation). Homebrew is a package manager
  that simplifies installing software. Follow [this
  guide](https://mac.install.guide/homebrew/index.html) to install Homebrew.
</Aside>

### Install Node.js

Node.js lets you run JavaScript code on your computer. The version you need depends on your edition:

| Edition | Node.js                                 |
| ------- | --------------------------------------- |
| Astro   | 22.12.0 or later                        |
| Tina    | 22.23.4 or later on Node 22, or Node 24 |
| Sanity  | 22.12.0 or later                        |

The Tina edition needs the newer version because Tina's command line tool supports only those two. Here's how to install Node.js on your operating system:

<Tabs>
  <TabItem label="Windows">

    Follow these steps to install Node.js on Windows:

    1. Download the latest **LTS version** of Node.js from the official website: [Node.js Downloads](https://nodejs.org/en/download/)
    2. Run the installer after it's downloaded, and follow the on-screen instructions. The installer will guide you through the process.
    3. After installation, open the **Command Prompt** (search for "cmd" in the Start menu) and verify the installation by typing the following command and pressing Enter:

    ```bash
    node -v
    ```

    If Node.js was installed correctly, you'll see the version number. Check it against the table above.

    <Aside type="tip">
      If you run into any issues, you can use **Chocolatey** (a Windows package manager) to install Node.js. Open the **Command Prompt** and run:

      ```bash
      choco install nodejs-lts
      ```
    </Aside>

  </TabItem>

  <TabItem label="macOS">

    Here's how to install Node.js on macOS:

    1. First, make sure you have [Homebrew](https://brew.sh/) installed. Homebrew is a tool that makes installing software easy. If you don't have it, follow [this guide](https://mac.install.guide/homebrew/index.html) to install it.
    2. Open your **Terminal** (you can find it in Applications > Utilities) and run this command to install Node.js:

    ```bash
    brew install node
    ```

    3. After installation, verify Node.js by typing the following command:

    ```bash
    node -v
    ```

    If everything is set up, the terminal will display the installed version of Node.js. Check it against the table above.

    <Aside type="tip">
      If you prefer, you can also download the installer directly from the official [Node.js Downloads](https://nodejs.org/en/download/) page instead of using Homebrew.
    </Aside>

  </TabItem>

  <TabItem label="Linux">

    To install Node.js on Linux, follow these steps:

    1. Open your **Terminal** and update your package list:

    ```bash
    sudo apt update
    ```

    2. Install Node.js using your package manager:

    ```bash
    sudo apt install nodejs
    ```

    3. Optionally, install npm (Node.js package manager) by running:

    ```bash
    sudo apt install npm
    ```

    4. Verify the installation by typing:

    ```bash
    node -v
    ```

    The installed version of Node.js will be displayed if everything worked correctly. Check it against the table above. Some package lists hold an older version, and then you need the official guide below.

    <Aside type="tip">
      For other Linux distributions, check the [official Node.js installation guide](https://nodejs.org/en/download/package-manager/) for additional instructions.
    </Aside>

  </TabItem>
</Tabs>

💡 **Need help?** Check out the official [Node.js installation guide](https://nodejs.org/en/download).

---

### **Setting Up Stella**

Once Node.js is installed, unzip the theme. Your edition is in the `themes` folder inside the zip: `themes/stella` for Astro, `themes/stella-tina` for Tina, and `themes/stella-sanity` for Sanity. Not sure which edition you need? See [Editions](../../features/editions/).

Stella uses **npm**, and its exact versions are in `package-lock.json`.

#### Install Dependencies

Open a terminal in your theme folder and run:

```bash
npm ci
```

This will install all the necessary dependencies for Stella.

#### Start the Development Server

To start the local development server and view your site on your computer, run:

```bash
npm run dev
```

🔹 Your site will be available at **http://localhost:4321**.

- **Tina edition:** the visual editor is at `http://localhost:4321/admin/`. Click **Enter Edit Mode**. You need no account. See [Tina](../../features/tina/).
- **Sanity edition:** the site runs straight away with the demo content, with no account. To edit it, run `npm run setup`, then `npm run dev:all`, and open the Studio at `http://localhost:3333`. See [Sanity](../../features/sanity/).

<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>

#### Create a Production Build

To generate an optimized production build of your site, run the following command in your project root:

```bash
npm run build
```

This will compile your project, optimize assets, and prepare everything for deployment. The output will be located in the `dist/` folder.

#### Preview the Production Build

To see how your site will look in the final production version, run:

```bash
npm run preview
```

This allows you to preview how the theme will look once it's live on the internet.

## Available Scripts

This guide covers the npm scripts available in Stella. These scripts help you develop, build, and manage your site efficiently.

---

### **Development Scripts**

#### `dev`

Starts the development server and keeps your configuration up to date.

```bash
npm run dev
```

**What it does:**

- Watches `src/config/config.toml` for changes
- Starts the Astro development server
- Enables hot module replacement (HMR) for instant updates
- In the Tina edition, also starts the visual editor at `/admin/`

🔹 Your site will be available at **http://localhost:4321**

---

#### `toml:watch`

Turns `config.toml` into the settings file the site reads.

```bash
npm run toml:watch
```

**What it does:**

- Reads `src/config/config.toml` once and writes the generated settings

<Aside type="note">
  `dev`, `build`, `preview`, `astro-check`, and `test` do this for you, so you
  typically don't need to run it manually.
</Aside>

---

### **Build Scripts**

#### `build`

Creates an optimized production build of your site.

```bash
npm run build
```

**What it does:**

- Generates the settings from `config.toml`
- Builds your site for production
- Removes draft pages from the sitemap
- Outputs the final build to the `dist/` folder

---

#### `preview`

Builds and previews your production site locally.

```bash
npm run preview
```

**What it does:**

- Runs the complete build process
- Starts a local preview server
- Allows you to test the production build before deployment

---

### **Quality Assurance Scripts**

#### `astro-check`

Runs type checking and diagnostics on your Astro project.

```bash
npm run astro-check
```

**What it does:**

- Checks for TypeScript errors
- Validates Astro components
- Reports potential issues in your code

---

#### `format`

Formats your source code using Prettier.

```bash
npm run format
```

**What it does:**

- Formats all files in the `./src` directory
- Ensures consistent code style across your project

---

#### `test`

Runs the test suite once.

```bash
npm run test
```

**What it does:**

- Runs Jest tests with a custom TypeScript configuration

To re-run the tests when files change, use `npm run test:watch`.

---

### **Utility Scripts**

#### `generate-favicons`

Generates favicon files from your source image.

```bash
npm run generate-favicons
```

**What it does:**

- Creates favicons in multiple sizes
- Generates necessary icon formats for different platforms

<Aside type="tip">
  Run this script after updating your site's logo or branding to ensure all
  favicon files are regenerated.
</Aside>

---

#### `generate-multilingual-content`

Adds a language to your site. It needs the language's details, so see [Internationalization](../../customization/internationalization/) for the full command.

**What it does:**

- Adds the language to `src/config/language.json`
- Makes copies of your default language to translate

---

#### `remove-multilingual`

Removes every language except your default one.

```bash
npm run remove-multilingual
```

**What it does:**

- Cleans up the other languages' content
- Useful when reverting to a single-language setup

<Aside type="caution">
  This script will remove multilingual content. Make sure to back up any
  important files before running it. [Internationalization](../../customization/internationalization/)
  has the steps for each edition.
</Aside>

---

#### `remove-draft-from-sitemap`

Removes draft pages from the generated sitemap.

```bash
npm run remove-draft-from-sitemap
```

**What it does:**

- Filters out pages marked as drafts, or with `excludeFromSitemap`, from the sitemap
- Ensures only published content appears in search engines

<Aside type="note">
  This script is automatically run during the `build` and `preview` commands, so
  you typically don't need to run it manually.
</Aside>

---

#### `deploy:cf`

Deploys the built site to Cloudflare Pages with Cloudflare's Wrangler tool. Wrangler isn't installed with the theme, so [install it](https://developers.cloudflare.com/workers/wrangler/install-and-update/) first.

```bash
npm run deploy:cf
```

---

### **Tina Edition Scripts**

| Script                  | What it does                                                         |
| ----------------------- | -------------------------------------------------------------------- |
| `npm run tina:generate` | Rebuilds the editor's forms after you add a section, field, or language |
| `npm run tina:audit`    | After you change content files by hand, tells you if a save would lose anything |
| `npm run setup:tina`    | Walks you through online editing with your own Tina Cloud project    |

### **Sanity Edition Scripts**

| Script                                       | What it does                                                    |
| -------------------------------------------- | --------------------------------------------------------------- |
| `npm run setup`                              | Logs you in, creates your project, writes `.env`, and uploads the demo content |
| `npm run dev:all`                            | Starts the website and the Studio together                      |
| `npm run studio`                             | Starts the Studio on its own                                    |
| `npm run import-seed`                        | Uploads the demo content again, replacing documents with the same IDs |
| `npm run import-seed -- --missing`           | The same, but keeps documents you already have                  |
| `npm run sanity:validate`                    | Checks the Studio's schema                                      |
| `npm run build:preview`, `npm run start:preview` | Build and start the Node.js preview server. See [Sanity](../../features/sanity/) |
| `npm run studio:build`, `npm run studio:deploy`  | Build the Studio, and put it online                         |

---

🚀 **You're all set!** Now you can start customizing Stella to fit your needs. 🎨