# Section Layouts

## Section Layouts

**Files:** page files in `src/pages/[...lang]/`, `src/content/sections/<language>/` · **Skill level:** Light code

Many kinds of section come in more than one layout. The hero, for example, has three: a navy panel with a portrait (Home 1), a light framed photo with a stat card (Home 2), and a full-width photo (Home 3). Each layout is its own component with its own content file.

### How Layouts Work In Covena
Every section file has an `options.layout` value with a comment beside it:

```yaml
# src/content/sections/english/hero-portrait-navy.md
options:
  # Hero layouts: portrait-navy (this file, Home 1) | framed-light (Home 2) | photo-full (Home 3).
  # Each layout is its own component in src/layouts/components/sections/hero/.
  layout: "portrait-navy"
```

The value is a **label**. Changing it does nothing to the page. The comment is the useful part: it lists the other layouts of that kind and the page where each one is used.

To use another layout, you swap the component in the page file.

### Swap A Layout
Example: use the Home 2 hero (`framed-light`) on Home 1.

<Steps>

1. Open `src/pages/[...lang]/index.astro`.

2. Replace the import and the tag of the current layout with the other one:

   ```astro
   ---
   // before
   import HeroPortraitNavy from "@/components/sections/hero/HeroPortraitNavy.astro";
   // after
   import HeroFramedLight from "@/components/sections/hero/HeroFramedLight.astro";
   ---

   <!-- before -->
   <HeroPortraitNavy content={heroPortraitNavy} />
   <!-- after -->
   <HeroFramedLight content={heroFramedLight} />
   ```

   Also rename `heroPortraitNavy` to `heroFramedLight` in the list of blocks the file reads from `data`, near the top.

3. If the page's content file has a block for the old layout, rename it to match (`heroPortraitNavy:` becomes `heroFramedLight:` in `src/content/homepage/<language>/-index.md`), in every language.

4. The new layout reads its defaults from its own file, here `hero-framed-light.md`. Edit that file, or put the changes in the renamed block.

</Steps>

The order of the tags in the page file is the order on the page, so you can also move a section by moving its line.

<Aside type="note">
  Layouts of the same kind don't share fields. `hero-framed-light.md` has
  stats that `hero-portrait-navy.md` doesn't, for example. Open the new
  layout's file to see what it needs.
</Aside>

### Every Layout
| Kind         | Layouts (component in `src/layouts/components/sections/`)                                                         | Where the theme uses each                                          |
| ------------ | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| Hero         | `portrait-navy` (`hero/HeroPortraitNavy`), `framed-light` (`hero/HeroFramedLight`), `photo-full` (`hero/HeroPhotoFull`) | Home 1, Home 2, Home 3                                          |
| About        | `collage` (`about/AboutCollage`), `statement` (`about/AboutStatement`), `vision-split` (`about/AboutVisionSplit`) | Home 1, Home 2, About and History                                  |
| Practice areas | `grid-navy` (`practice/PracticeGridNavy`), `rows` (`practice/PracticeRows`), `situations` (`practice/PracticeSituations`) | Home 1 and `/practice-areas/`, Home 2, Home 3              |
| Process      | `photo-cards` (`process/ProcessPhotoCards`), `steps-line` (`process/ProcessStepsLine`)                            | Home 1 and About, Home 3                                           |
| Testimonials | `slider` (`testimonial/TestimonialSlider`), `quote-centred` (`testimonial/TestimonialQuoteCentred`)                | Home 1 and `/practice-areas/`, Home 3                              |
| Team         | `carousel` (`team/TeamCarousel`), `grid-4` (`team/TeamGrid4`), `panel` (`team/TeamPanel`)                         | Home 2, Home 3, About                                              |
| Stats        | `band-bronze` (`stats/StatsBandBronze`), `portraits-band` (`stats/StatsPortraitsBand`)                            | About, Home 2                                                      |
| Insights     | `bronze-panel` (`insights/InsightsBronzePanel`), `featured-list` (`insights/InsightsFeaturedList`)                | Home 1 and insight posts, Home 2                                   |
| Contact      | `split-form` (`contact/ContactSplitForm`), `callback-panel` (`contact/ContactCallbackPanel`)                       | Home 1 and inner pages, Home 3                                     |
| Call to action | `band-navy` (`cta/CtaBandNavy`), `panel-centered` (`cta/CtaPanelCentered`)                                      | Home 2, Careers, History, Recognition, Fees and Results            |
| FAQ          | `split` (`faq/FaqSplit`), `tabs` (`faq/FaqTabs`)                                                                  | Home 3, `/faq/` (the tabs read their groups from `src/content/faq/<language>/-index.md`) |
| Logos and awards | `logos-row` (`logos/LogosRow`), `awards-badges` (`recognition/RecognitionAwardsBadges`)                       | Home 2, Home 3                                                     |

These kinds have one layout each: features (`trio`, Home 1), why us (`accordion-panel`, Home 1 and `/practice-areas/`), industries (`marquee-cards`, Home 2), results (`cards`, Home 2), fees (`fixed-fees`, Home 3), values (`rows`, About and Careers), the newsletter (`panel`, Insights) and search (`list`).

### Surfaces
Some components take a `surface` prop in the page file that changes their background, not their layout. These come from the comments in the section files:

- `ContactSplitForm` with `surface="cream"` sits in a white panel. Inner pages use it this way, Home 1 doesn't.
- `TestimonialSlider` with `surface="panel"` sits in a white panel (`/practice-areas/`).
- `WhyUsAccordionPanel` with `surface="page"` drops its panel and sits on the page colour (`/practice-areas/`).

### Page Headers
Inner pages open with one of two page headers, set in the page file:

- `page-header/PageHeaderCentred`: a centred title and description. Most inner pages, the legal pages and the insights list use it.
- `page-header/PageHeaderNavy`: the title and description in a navy band, with an optional image. Industries, History, Careers and the office pages use it.

Both read the page's own `title` and `description`, so you change the text in the page's content file.

### See Them On One Page
Run `npm run dev` and open `http://localhost:4321/components/`. That page shows the shared pieces you can use in Markdown (buttons, accordions, tabs, notices, tables, images) and every scroll motion pattern. For the section layouts themselves, open the three homepages: between them they use almost every layout.

### Do It With AI
```text
On Home 1 (src/pages/[...lang]/index.astro), replace the testimonial slider with the
quote-centred layout (TestimonialQuoteCentred). Update the import, the tag and the block name it
reads, and rename any testimonialSlider block in src/content/homepage/<language>/-index.md to
testimonialQuoteCentred in every language. Keep the other sections as they are. Then run
npm run astro-check and npm run build.
```