Your first page
Create a page in the admin, fill it with sections and publish it, as an editor would. Then look at the code that decided what the editor was allowed to do.
Create the page
This page assumes the Lorem Co. starter from Install, running on your machine. The steps in the admin are the same for every framework.
- Open
/adminon your running site and sign in. - On Pages, click + New page.
- Enter
servicesas the slug, the last part of the page's URL.
Lorem Co. has one page type that editors can create, so the admin skips that question and opens the new page. On a site with several page types, it asks which one to use.
Edit it in the canvas
The editor shows the page as the site renders it (the canvas) on the left, and the fields of whatever you select (the inspector) on the right.
- Click the hero at the top. It is marked locked: editors fill its fields but cannot move or remove it.
- In the inspector, change Heading to
Services. The canvas updates as you type, and Saved appears at the top. Every change saves as a draft on its own; nothing is live yet. - Click Add section under the hero and pick Points. It arrives filled with sample content, so the page never shows an empty section.
- Change the section's Heading to
What we do. The toolbar on the selected section moves it up or down, duplicates it or removes it.
The switch at the top right (next to the eye button) turns the canvas into the structure view: every section is a card with its title and a line of its content. Drag a card by its grip to reorder the page, click a card to edit its fields in the inspector, and switch back to see the page as the site renders it. As with every edit, the live site changes nothing until you publish.
Every change can be taken back: Cmd+Z (Ctrl+Z on Windows and Linux), or the left arrow at the top right, undoes the last edit step by step, and Shift+Cmd+Z or the right arrow brings it back. A burst of typing is one step.
To reuse a section on another page, pick Copy in the section's ⋯ menu (on its card in the structure view, or on its row in the Page Outline), and on the other page pick Paste before or Paste after in a card's or row's ⋯ menu, or Paste on a zone's heading in the structure view. The entry is greyed out when that page's zone does not allow the section.
Publish
Click Publish at the top right. The status next to it changes from Draft to Published, and the eye button (View live) opens the page at /services on your site.
A new page's title starts as its slug, so the browser tab says "services". To change it, go back to Pages, open the ⋯ menu at the end of the page's row and pick Rename…. The admin asks for the title and then the slug; enter Services and keep the slug. The title changes on the live page at once.
Why the editor could do that
Everything the editor was allowed to do comes from the page type's schema. It is the same file in every framework; in an Astro project it lives under src/components/pages/.
export const pageSchema = smoodly.schema.page({
name: "page",
title: "Page",
zones: {
hero: z.locked(pageHeroSchema),
body: z.freeform({ sections: [imageTextSchema, pointsSchema, favouriteArticlesSchema, peopleSchema, quoteSchema], custom: true }),
},
// …
});The page type's view decides where each zone renders:
---
import { Zone } from "smoodly/astro/components";
// …
---
<Layout head={head} locale={page.locale} locales={page.locales}>
// …
<Zone of={zones.hero} />
<Zone of={zones.body} />
</Layout>The file's name pairs it with the schema named page.
import { smoodly, Zone, type Props } from "smoodly/react";
// …
<Zone of={zones.hero} />
<Zone of={zones.body} />
// …
export const StandardPage = smoodly.page(pageSchema, PageView);smoodly.page() pairs it with the schema.
Each zone is a place on the page where editors work, and its policy sets how much they may change:
z.locked(PageHero)Exactly one page hero. Editors fill its fields but cannot add, move or remove it.z.freeform({ … })Any number of the listed sections, in any order. custom: true also offers the custom section, which editors lay out themselves.The form in the inspector came from the Points section's own definition: one field for the heading and a list of one to six points. Change a field there and the form changes with it.
Next, Sections shows how to write a section of your own, and Zones and freedom covers the three zone policies.