# Editing Safely

## Editing Safely

**Skill level:** Complete beginner

Nothing you change in Consultiz is permanent if you keep checkpoints. These habits make every edit safe to try, whether you edit by hand or with an AI assistant.

New to the file formats? Read [Markdown And Frontmatter Basics](/common-guide/beginner/markdown-frontmatter/) and [Config Basics](/common-guide/beginner/config-basics/) in the common guide first.

### The Safe Editing Loop
<Steps>

1. **Run the site** with `npm run dev`, so you see each change as soon as you save.
2. **Change one thing**, save, and look at the page.
3. **Check the phone layout** by making the browser window narrow.
4. **Check the French page** (`/fr/...`) if you changed English text.
5. **Save a checkpoint** when it works (see below).

</Steps>

Small steps make problems easy to find: if the page breaks, it was the last change.

### Save Checkpoints With Git
Before you change anything, save the untouched theme as your first version:

```bash
git init
git add .
git commit -m "Consultiz as downloaded"
```

Then, after each working change:

```bash
git add .
git commit -m "Change banner text and brand color"
```

- **See what changed** since the last checkpoint: in VS Code's **Source Control** panel, click a file. Removed lines are red, added lines are green.
- **Undo changes to one file**: right-click it in Source Control and choose **Discard Changes**.
- **Undo everything since the last checkpoint**: `git restore .` in the terminal.

No git? Copy the whole project folder (without `node_modules/`) before a big change, and name the copy with the date.

### Keep YAML, TOML, And JSON Valid
- **YAML (frontmatter):** keep the `---` lines, indent with spaces (never tabs), put text containing a `:` in quotes, and write `true` and `false` without quotes. A line starting with `#` is a comment.
- **TOML (`config.toml`):** `key = value`, text in quotes, and each key belongs to the `[table]` above it.
- **JSON (menus, i18n, fonts):** double quotes around keys and text, a comma between items, and no comma after the last item.

### Before You Change Code
Content files are hard to break. Components and styles are easier to break and harder to fix. Before you edit anything in `src/layouts/` or `src/styles/`:

- check whether the change can be made in a content file or `config.toml` instead (it usually can)
- save a checkpoint
- run `npm run astro-check` afterwards

### Run The Checks
```bash
npm run astro-check   # finds mistakes in code and content files
npm run build         # builds the full site, as your host will
```

Run both before every deploy. Stop `npm run dev` first. `npm run verify` runs these and the theme's other checks in one go; see [Installation](/consultiz/getting-started/installation/).

Section files are only loosely checked, so the safe editing loop above (look at the page after each change) is your check for them. If `npm run build` prints a `[site]` warning, set `baseUrl` in `config.toml` before you deploy.

<Aside type="caution">
  Never edit files in `.astro/`, `dist/`, or `node_modules/`. They are
  generated and your changes would be lost.
</Aside>