GlobalsHeader and footer

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.

View as Markdown

The sections

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

components/sections/Header.schema.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): on Astro they arrive with the page's own read, so rendering them costs no extra call.

Rendering them

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

src/layouts/Layout.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.

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. Publishing a page never publishes the footer, because a footer going live on every page is a deliberate click.

Next, The media library.

Edit this page on GitHubLast updated 6 Oct 2026