# How Covena Works

## How Covena Works

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

Read this page once and the rest of the docs will make sense. Covena is built from a few ideas that repeat on every page.

### The Big Picture
Covena is a **static site**. When you run `npm run build`, it turns your text files into finished HTML pages in `dist/`. There is no database and no admin panel: your files are the website.

```text
config.toml ──► site settings, phone and email, forms, header, quick exit, motion, SEO
menu.en.json ─► header and footer links
theme.css ────► colors, radii, spacing, type scale, breakpoints
en.json ──────► button labels, form messages, main address, tagline

ROUTE  src/pages/[...lang]/index.astro
  │    which sections, in which order, which header and footer
  │
  ├─ PAGE  src/content/homepage/english/-index.md
  │        title, SEO, named blocks for this page only
  │
  └─ each SECTION
       ├─ default: src/content/sections/english/hero-portrait-navy.md
       └─ + page block: heroPortraitNavy: { ... }

Base.astro wraps every page:
  head · cookie banner · header · page · footer · back-to-top button
```

### 1. Routes Decide What A Page Shows
Each file in `src/pages/[...lang]/` is one page (a **route**). It lists the sections that page shows, top to bottom, and picks the header and footer. This is Home 1, `src/pages/[...lang]/index.astro`, shortened:

```astro
<Base
  {...data}
  headerVariant="panel"
  headerOverlay={true}
  footerVariant="marquee">
  <HeroPortraitNavy content={heroPortraitNavy} />
  <FeaturesTrio content={featuresTrio} />
  <AboutCollage content={aboutCollage} />
  <PracticeGridNavy content={practiceGridNavy} />
  ...
  <ContactSplitForm content={contactSplitForm} />
</Base>
```

To move a section, move its line. To remove it from this page, delete its line, or hide it from the content file with `enable: false` (see step 3). The `[...lang]` folder makes every route exist once per language: `/`, `/fr/`, and `/ar/`.

### 2. Sections Have Default Content
Each section reads its text and images from one file in `src/content/sections/<language>/`. The hero above reads `hero-portrait-navy.md`. Change that file and the section changes on every page that uses it. `src/layouts/components/sections/section-ownership.md` lists every section with its file and its pages.

### 3. Pages Can Override Any Section
To change a section on one page only, add a block with the section's name to that page's content file. The homepage files list their block names in a comment at the top:

```yaml
# src/content/homepage/english/-index.md
heroPortraitNavy:
  title: "Plain legal advice for <em>you</em>"
```

Only the fields you write change. The rest still comes from the section file.

### 4. How Overrides Merge
- Fields you leave out keep the default.
- Nested objects merge, so changing a button's `label` keeps its `url`.
- Lists replace the whole default list: copy every item you want to keep. `[]` clears the list.
- An empty string (`""`) clears a value.
- `enable: false` hides the section on that page.
- One word wrapped in `<em>` in a title is set in the accent serif font.

See [Sections](/covena/customization/sections/) for the details.

### 5. Layouts Are Separate Components
Sections are named by kind and layout: `hero/HeroPortraitNavy.astro` reads `hero-portrait-navy.md`, and `hero/HeroFramedLight.astro` reads `hero-framed-light.md`. The `options.layout` value in a section file is a label, and the comment next to it lists the other layouts of that kind. To use another layout on a page, import its component in the route file in place of the current one. See [Section Layouts](/covena/customization/section-layouts/).

### 6. Base Wraps Every Page
`src/layouts/Base.astro` adds the head tags, the cookie banner, the header, the footer, the back-to-top button, and the scripts. Each route passes it a few props:

| Prop             | Values                                     | Default   |
| ---------------- | ------------------------------------------ | --------- |
| `headerVariant`  | `panel`, `bar`, `transparent`              | `panel`   |
| `headerOverlay`  | `true` lets the header float over the first section | `false` |
| `footerVariant`  | `marquee`, `columns-light`, `offices`      | `marquee` |
| `footerReveal`   | `true` slides the page up off the footer   | `false`   |

See [Header](/covena/customization/header/) and [Footer](/covena/customization/footer/).

### 7. Firm Details Are Set Once
The main phone and email are in `[settings.contactInfo]` in `config.toml`. The main address is `contactInfo.address` in each `src/i18n/<lang>.json`, so it can be written the local way. The offices are files in `src/content/offices/`. The header chips, the footers, and the call links read these, so you change them in one place. See [Firm Info](/covena/customization/firm-info/).

### 8. Small Interface Text Lives In i18n Files
Button labels, form messages, the results disclaimer, the price format, and the footer sentences are in `src/i18n/en.json`, `fr.json`, and `ar.json`. All three files have the same keys. See [Internationalization](/covena/customization/internationalization/).

### 9. Config Is Converted Before Astro Reads It
Astro can't read TOML directly, so `npm run dev` and `npm run build` first turn `src/config/config.toml` into `.astro/config.generated.json`. While the dev server runs, every save of `config.toml` does this again. Never edit the generated file.

### 10. Collections Hold The Repeated Content
Practice areas, industries, attorneys, results, offices, careers, and insights are **collections**: one Markdown file per entry, plus `-index.md` for the list page. `weight` sets the list order (lower comes first), and `draft: true` keeps an entry out of the production build. Practice areas, industries, results, and offices share part of their detail pages through `detailDefaults` in `-index.md`, so each entry only sets what differs. See [Collections](/covena/customization/collections/).

### 11. What Happens During A Build
<Steps>

1. `config.toml` is converted to JSON.
2. Astro checks every content file against its fields (`src/content.config.ts` and `src/sections.schema.ts`). A wrong value stops the build and names the file and field.
3. Every route is rendered once per language into `dist/`. Internal links get the language prefix on French and Arabic pages.
4. The sitemap, `robots.txt`, the RSS feeds, `llms.txt`, `llms-full.txt`, and the Markdown copies of pages are written.
5. If the site URL is not set, a yellow `[site]` warning prints, and the sitemap is skipped.

</Steps>

### Development vs. Production
| | `npm run dev` | `npm run build` |
| --- | --- | --- |
| What you get | A live site at `localhost:4321` that updates as you save | Finished files in `dist/` to upload |
| Draft pages | Shown | Left out |
| Forms with no endpoint | Demo mode, with a hint naming the setting to fill in | Demo mode, with a plain "nothing was sent" message |
| Speed | Pages build when you open them | Every page is built at once |

### Find Where Any Text Comes From
If you see text on a page and don't know where it lives, look in this order:

1. The page's own file, in a named block (`src/content/<page>/<language>/-index.md`, or `src/content/homepage/<language>/` for the homepages)
2. The section's default file (`src/content/sections/<language>/`)
3. A collection entry (`src/content/practice-areas/`, `attorneys/`, `results/`, `offices/`, `careers/`, `blog/`, …)
4. The interface text (`src/i18n/<lang>.json`)
5. The menus (`src/config/menu.<lang>.json`)
6. Site settings (`src/config/config.toml`)

<Aside type="tip">
  Your code editor's search across files (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> +
  <kbd>F</kbd> in VS Code, <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>F</kbd> on a
  Mac) finds any sentence in seconds. Search for a few words you can see on
  the page.
</Aside>