# Header and footer

The starter's header and footer are visual globals rendered by your layout, not sections placed on pages. This page walks through how they are defined, rendered and edited.

## The sections

The header is a section like any other, with one difference in its schema:

File: `components/sections/Header.schema.ts`

```ts
export const headerSchema = smoodly.schema.section({
  name: "header",
  title: "Header",
  description: "The site header: brand and navigation.",
  fields: {
    brand: f.text(),
    nav: f.list(f.object({ label: f.text(), href: f.link() })).localized(),
  },
  sample: { brand: "Lorem Co.", nav: [{ label: "Home", href: "/" }] },
  // Nobody pads the header from the editor: no Spacing & layout group.
  styles: false,
});
```

`styles: false` takes away the *Spacing & layout* group, because the header's spacing is the design's. The brand is shared across languages and the navigation is localized as a whole, so each language has its own labels and links. The footer follows the same pattern with a tagline, three link columns and a copyright line.

Both are registered in `smoodly/sections.ts` and named with `smoodly.global()` in `smoodly/globals.ts`, which gives each a row under *Sections* and its `sample` as starting content. No zone lists them, so the *Add section* picker never offers them. Both are `layout: true` ([Defining a global](https://smoodly.io/docs/globals/defining.md#layout-globals)): on Astro they arrive with the page's own read, so rendering them costs no extra call.

## Rendering them

**Astro**

The layout reads the header, the footer and the contact details as live entries, and renders the sections' views with the values spread:

File: `src/layouts/Layout.astro`

```astro
---
// …
const [{ entry: header }, { entry: footer }, { entry: contact }] = await Promise.all([
  getLiveEntry("header", { locale }),
  getLiveEntry("footer", { locale }),
  getLiveEntry("contact", { locale }),
]);
const codes = Object.keys(locales);
const links = codes.length > 1
  ? codes.map((code) => ({ code, url: href(locales[code]?.path ?? "/", code), current: code === locale }))
  : undefined;
---
// …
    {header && <Header {...header.data.fields} settings={header.data.settings} styles={header.data.styles} home={href("/", locale)} locales={links} />}
    <main><slot /></main>
    {footer && <Footer {...footer.data.fields} settings={footer.data.settings} styles={footer.data.styles} contact={contact?.data.fields} />}
```

The footer's view takes one prop its schema does not have, the contact object; a view is a plain `.astro` file and accepts anything. The header's language links need the page on screen, and in Astro the layout knows it: every page view passes its own `locales` map to the layout, which Astro renders after the page.

**Next.js**

The root layout reads the footer and the contact details and renders the footer's view:

File: `app/[locale]/layout.tsx`

```tsx
import { FooterView } from "@/components/sections/Footer";
import { q } from "@/smoodly/server";
// …
  const [footer, contact] = await Promise.all([
    q().getGlobal("footer", { locale }),
    q().getGlobal("contact", { locale }),
  ]);
  return (
    <html lang={locale} className={`${serif.variable} ${sans.variable}`}>
      <body>
        <NextIntlClientProvider>
          {children}
          {footer && <FooterView {...footer.fields} settings={footer.settings} styles={footer.styles} contact={contact?.fields} />}
        </NextIntlClientProvider>
      </body>
    </html>
  );
```

The layout renders `FooterView`, the view, rather than `Footer`, the paired component, because it passes one prop the footer's schema does not have: the contact object. A paired component accepts only its schema's fields; a view is a plain component and accepts anything. The footer exports both.

The header is not in the layout. A layout cannot know which page is on screen, and the language links in the header must land on the same page in the other language. So every page type renders the header itself, through the starter's `PageFrame`, from the page's own language map:

File: `components/PageFrame.tsx`

```tsx
export async function PageFrame({ locale, locales, children }: {
  locale: string;
  locales: Record<string, LocaleAlternate | null>;
  children: ReactNode;
}) {
  const header = await q().getGlobal("header", { locale });
  const codes = Object.keys(locales);
  const links: LocaleLink[] | undefined = codes.length > 1
    ? codes.map((code) => ({ code, url: href(locales[code]?.path ?? "/", code), current: code === locale }))
    : undefined;
  return (
    <>
      {header && <HeaderView {...header.fields} settings={header.settings} styles={header.styles} home={href("/", locale)} locales={links} />}
      <main>{children}</main>
    </>
  );
}
```

On a single-language site there are no links and the header shows the brand and navigation alone. [Language switcher and hreflang](https://smoodly.io/docs/languages/language-switcher.md) covers the `locales` map.

## Editing them

Editors change the header and footer under *Globals*, or in any page's canvas: both are selectable there, tagged *global*, with their own form and their own *Publish* in the inspector. The header's navigation edits in place like any list with [marks](https://smoodly.io/docs/content-modeling/marks.md). Publishing a page never publishes the footer, because a footer going live on every page is a deliberate click.

Next, [The media library](https://smoodly.io/docs/media/library.md).
