Try “optimization”, “doctor” or “page body”.

    v1.2.2
    Docs menu
    Docs › Guides

    Create a page type

    Add a new kind of routable page, such as case studies, with its own URL, allowed components and listing.

    A page type is a content type that becomes a URL. ACES ships with two: Page (/[...slug]) and Article (/articles/[slug]). This guide adds Case Study pages at /case-studies/[slug], with a listing at /case-studies. Case studies allow only a few components.

    1. Choose the body

    A page type’s body is either:

    • a page body: a named list of components editors can stack, like Page
    • richText: a single rich text field, like Article

    Case studies should allow Hero, Rich Text Section and the Logo Wall, so create a page body for them:

    pnpm aces page-body add "Case Study" --components hero,richtextsection,"logo wall"
    ✓ aces.config.ts: pageBodies.caseStudy (3 components)
    // aces.config.ts
    pageBodies: {
      default: { title: "Page Body", components: [/* … */] },
      caseStudy: { title: "Case Study", components: ["Hero", "RichTextSection", "LogoWall"] },
    },

    Components are matched by key or title, so "logo wall" finds LogoWall. To share the default body instead, skip this step and pass --body default below.

    2. Run the CLI

    pnpm aces page add "Case Study" --body caseStudy --listing \
      --description "A customer story: the problem, the solution and the results."
    ▸ Scaffolding Case Study (/case-studies/[slug] + /case-studies)
    ✓ src/app/[lang]/case-studies/[slug]/services.ts
    ✓ src/app/[lang]/case-studies/[slug]/preview.tsx
    ✓ src/app/[lang]/case-studies/[slug]/page.tsx
    ✓ src/app/[lang]/case-studies/services.ts
    ✓ src/app/[lang]/case-studies/page.tsx
    ✓ aces.config.ts: pageTypes.caseStudy (Specialty Page "Case Studies Listing")
    ✓ Updated contentful/models.json

    What the command changed

    1. Routes under src/app/[lang]/case-studies/:

      File Role
      [slug]/services.ts Query by slug: title, SEO and the body’s block list
      [slug]/page.tsx The page: metadata from the entry’s SEO, then the page body (server components)
      [slug]/preview.tsx The Draft Mode version: live updates, client components
      services.ts + page.tsx The paginated listing at /case-studies
    2. Config:

      caseStudy: {
        title: "Case Study",
        contentType: "caseStudy",
        route: "/case-studies/[slug]",
        listing: "/case-studies",
        specialtyPage: "Case Studies Listing",
        body: "caseStudy",
      },
    3. Contentful:

      • a 📄 Case Study content type with title, slug, pageBody (limited to the three components) and seo (→ Metadata)
      • its Live Preview URL
      • Internal Link entries can now point at case studies, and resolve to /case-studies/<slug>
      • Case Studies Listing is added to the Page type’s Specialty Page options
    Flag Effect
    --path stories Use /stories/[slug] instead of the default plural of the name
    --body richText A single rich text body instead of a page body
    --specialty-page "<value>" Rename the listing’s Specialty Page value
    --no-model Code and config only. Create the content type yourself, then run pnpm aces sync --contentful.

    3. Give the listing its title and SEO

    The listing at /case-studies takes its heading and SEO from a regular Page entry:

    1. Create a Page in Contentful (for example, the title “Case Studies”).
    2. Set its Specialty Page to Case Studies Listing.
    3. Publish it.

    Links to that Page now resolve to /case-studies.

    4. Create one and preview it

    pnpm dev
    1. In Contentful, create a Case Study entry with a title and a slug (for example northwind), and add a Hero to its body.
    2. The Live Preview pane opens /case-studies/northwind in Draft Mode, and updates as you edit.
    3. Publish the entry. It appears at http://localhost:3000/case-studies/northwind and in the listing.

    Then run the checks:

    pnpm typecheck && pnpm lint && pnpm build
    pnpm aces doctor

    Change it later

    • Allow another component: add it to pageBodies.caseStudy.components, then run pnpm aces sync --contentful to update the field’s allowed types in the space.
    • Add a field (such as an industry or a client logo): add it to the content type, to [slug]/services.ts, and to page.tsx where it should render.
    • Remove it: pnpm aces page remove caseStudy, then pnpm aces page-body remove caseStudy. Add --delete-content-type to remove the type from the space as well.

    Something wrong or missing? Open an issue.