Concrete
Start

Add a section and a page

Growing past the starter — a second section, a second page, and navigation between them.

The loop from the last page, one level up: a section is a value you export, a page is a component that places sections, and the template's pages object is the site map.

Goal

A second page at its own path, with its own section, reachable from the hero.

Steps

Write the section. Nothing new here — the same declaration and markup as the hero, in its own file. nav.selfAnchor is the id the framework assigns this instance, so an anchor elsewhere can reach it:

sections/details.tsx
import { fact, fill, Section, section, Slot, text } from "@homepages/concrete";

export const Details = section(
  {
    key: "details",
    label: "Details",
    slots: {
      heading: text.medium({
        label: "Heading",
        cap: 60,
        source: fill.write({
          reads: [fact.property.description],
          brief: "Name what this page covers, in one short, plain line.",
        }),
      }),
      body: text.long({
        label: "Body",
        cap: 600,
        source: fill.write({
          reads: [fact.property.description],
          brief:
            "Describe the layout and the finishes a buyer would notice walking in, in one paragraph. Warm and concrete, no adjectives you cannot see in a photo.",
        }),
      }),
    },
  },
  ({ slot, nav }) => (
    <Section id={nav.selfAnchor} className="bg-white text-neutral-900">
      <div className="mx-auto max-w-3xl px-6 py-24">
        <Slot.Text slot={slot.heading} as="h1" className="text-3xl font-semibold tracking-tight" />
        <Slot.Text slot={slot.body} as="p" className="mt-6 text-lg text-neutral-600" multiline />
      </div>
    </Section>
  ),
);

Export it. Sections are found by walking the exports of the modules your pages import, so a section a page places but nothing exports cannot be bundled on its own — pages/section-not-exported.

Place it on a page. A page is a component with no props that returns sections and nothing else:

pages/details.tsx
// The section is your workspace's own module, which resolves in your tree and
// in no standalone fence here.
// @noErrors
import { Details } from "@/sections/details";

export const DetailsPage = () => <Details />;

@/ is the alias the scaffolded tsconfig.json points at the workspace root.

Declare the page. The object key is the page id, and the object order is the order the artifact carries:

template.ts
// The stylesheet, the icon and the two page modules are your workspace's own,
// which resolve in your tree and in no standalone fence here.
// @noErrors
import { defineTemplate, website } from "@homepages/concrete";

import "./globals.css";
import icon from "./icon.svg";
import { DetailsPage } from "./pages/details";
import { Home } from "./pages/home";

export default defineTemplate({
  key: "my-template",
  name: "My Template",
  format: website,
  icon,
  scope: "global",
  pages: {
    home: { label: "Home", path: "/", page: Home },
    details: { label: "Details", path: "/details", page: DetailsPage, optional: true },
  },
  fixtures: "./fixtures/index.json",
});

label is the name in the editor's page bar and in a navigation menu. path is one lowercase-kebab segment, and exactly one page in the object takes "/".

optional: true lets a user switch the whole page off: it then publishes nothing and drops out of the navigation. The root page can never be optional, because a site has to answer /.

fixtures is the starter's line, unchanged: it names the fixture list, the one way the framework finds the dev data.

Link to it. No URL is ever written by hand. A section reaches another page through nav.anchors, which resolves to a bare fragment on the same page and to the other page's URL plus the fragment across pages — the same code either way. Add the anchor to the hero's markup; the section is shortened to one slot here so that the link is the only new thing in it:

import { fact, fill, Section, section, Slot, text } from "@homepages/concrete";

const headline = text.medium({
  label: "Headline",
  cap: 60,
  source: fill.write({ reads: [fact.property.description], brief: "One confident, specific sentence on what makes the property worth seeing." }),
});

export const Hero = section(
  { key: "hero", label: "Hero", slots: { headline } },
  ({ slot, nav }) => (
    <Section>
      <Slot.Text slot={slot.headline} as="h1" />
      {nav.anchors.details === undefined ? null : (
        <a href={nav.anchors.details} className="mt-6 inline-block underline">
          See the details
        </a>
      )}
    </Section>
  ),
);

The guard is the point on an optional page. A target behind a page the user has switched off is absent from the map rather than resolving to a page that publishes nothing, and absence is your signal to omit the control — an anchor with no href is a dead one. For a whole-site menu, read nav.pages: every page in composition order, with the hidden ones already dropped.

State the new section's content, and check. The fixture's content holds one entry per placed instance with filled slots, keyed <section key>-1:

fixtures/starter-home.json
{
  "$schema": "../.concrete/schema/content-fixture.schema.json",
  "property": "properties/starter/property.json",
  "content": {
    "hero-1": {
      "slots": {
        "headline": "A brick colonial on a quiet, tree-lined street",
        "hero_image": { "media": "exterior-front" }
      }
    },
    "details-1": {
      "slots": {
        "heading": "Inside the house",
        "body": "Oak floors run from the entry through to the kitchen, where a bay window looks over the garden."
      }
    }
  }
}
Terminal
npm run check
✓ workspace
✓ typecheck
✓ lint
✓ composition
✓ relations
✓ stylesheet
✓ logic
✓ fixtures
✓ sections
✓ contracts
✓ render
✓ bundles
    details  renderer 6.4 KB gzip
    hero     renderer 8.1 KB gzip
✓ dependencies

concrete check passed: 13 stages.

The bundles stage now names both sections: the composition stage found the second page, ran your pages under its probe, and every section it recorded is bundled and weighed.

concrete dev grows a second canvas, and the canvas bar switches between them. The optional page carries an eye in its frame title row — hide it, and the hero's link goes with it, because the navigation you read is resolved over the same display state the user is looking at.

One section, two pages, one instance

Placing the same section value on two pages does not give you two copies. It gives you a single instance rendered on both, so a user edits it once and sees it everywhere — which is exactly what a header and a footer want. A second, independent instance of the same section names itself, with instance= on the placement: <Hero instance="hero-2" />. The default id is the section's key with -1 after it, and pages and composition has the identity rules in full.

What you learned

  • What a section is, again. One exported value, found by import rather than by file name, with an explicit key for identity — sections.
  • What a page is. A composition read once by a probe: sections and nothing else, with path and optional as data the platform routes on — pages and composition.
  • What an instance is. One section placed anywhere is one content document; a second copy declares its own id — pages and composition.
  • Why navigation is read, not written. Links resolve over the display state the user is editing, so an optional page cannot leave a dead anchor behind — the pipeline.

Next

Check, build, publish — the end of the track.

On this page