# Zones and freedom

A zone is a place in a page type where editors add sections. Its policy sets how much they may change there, from filling one section's fields to placing any section in any order.

## The three policies

Every zone in `smoodly.schema.page()` takes one policy from `z`:

| Name | Description |
| --- | --- |
| `z.locked(heroSchema)` | Exactly one Hero, always. Editors fill its fields but cannot add, move or remove it. |
| `z.sections([heroSchema, pageHeroSchema])` | Any number of the listed sections, in any order. .max(n) caps how many. |
| `z.freeform({ sections: [...] })` | The same, plus custom: true to offer the custom section. sections: "*" allows every registered section. |

Policies name components, not strings, so a typo is a type error. One page type can mix all three:

**Astro**

The schema is the same file as in any framework. Its view, `src/page-types/landing.astro`, renders each zone with `<Zone of={zones.hero} />` from `smoodly/astro/components`, as on [Page types](https://smoodly.io/docs/content-modeling/page-types.md); a zone locked to a global renders the global's section.

**Next.js**

File: `components/pages/Landing.tsx`

```tsx
import { smoodly, z, Zone, type Props } from "smoodly/react";
import { heroSchema } from "@/components/sections/Hero.schema";
import { pageHeroSchema } from "@/components/sections/PageHero.schema";
import { quote } from "@/smoodly/globals";

export const landingSchema = smoodly.schema.page({
  name: "landing",
  title: "Landing",
  zones: {
    hero: z.sections([heroSchema, pageHeroSchema]).max(1),
    body: z.freeform({ sections: "*", custom: true }),
    closing: z.locked(quote),
  },
  seo: true,
});

function LandingView({ zones }: Props<typeof landingSchema>) {
  return (
    <>
      <Zone of={zones.hero} />
      <Zone of={zones.body} />
      <Zone of={zones.closing} />
    </>
  );
}

export const LandingPage = smoodly.page(landingSchema, LandingView);
```

The hero zone offers a choice of two openers and takes one of them. The body takes anything. The closing zone always shows the site's one quote, edited under *Sections*.

> **Note:** `sections: "*"` includes every registered section, the header and footer too. List the sections instead when some are only meant for the layout.

## What editors see

In the canvas, *Add section* appears between the sections of a zone and at its end. It opens a picker with the sections the policy allows, then *Custom section* where `custom: true`, then a *Global* group with the globals whose section is allowed there. A zone capped with `.max(n)` loses its *Add section* once it is full. The picker shows each section as your site draws it, filled where its `sample` is silent; its *Insert filled* switch, when turned off, inserts the section empty instead ([Sample content](https://smoodly.io/docs/content-modeling/sections.md#sample-content)).

A section's toolbar moves it up or down, duplicates it or removes it. In a locked zone the section is tagged *locked* and the toolbar says *fields only*. Smoodly fills the zone from the section's `sample` the first time the page opens.

An empty zone shows as a box in the canvas so it can take a section. On the site it renders nothing.

## Locking a zone to a global

`z.locked()` also takes a global with a section, as `closing` does above. The zone then shows that one global on every page of the type. Editors change it once, under *Globals* or right in any canvas that shows it, and every page follows. The starter's header and footer take a different route: the layout renders them directly, so they need no zone.

A global can also be placed by hand. The starter lists Quote in its body zones, so the picker's *Global* group offers the site quote there, and an editor may still add a one-off Quote from the sections list.

## Choosing a policy

- **Lock** what the design needs exactly once, in one place: the opener of every page type in the starter is a locked hero.
- **Sections with a list** for a slot with a few right answers: a hero zone that takes one of two openers.
- **Freeform** for the body. Most sites need it in one zone, with the sections you have built and `custom: true` for the layouts you have not.
- **Your own JSX** for what editors should never touch. It renders in the canvas but cannot be selected.

Next, [Settings, styles and CSS](https://smoodly.io/docs/content-modeling/styles-and-settings.md) covers what editors can change on a placed section beyond its fields.
