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
-
Routes under
src/app/[lang]/case-studies/:File Role [slug]/services.tsQuery by slug: title, SEO and the body’s block list [slug]/page.tsxThe page: metadata from the entry’s SEO, then the page body (server components) [slug]/preview.tsxThe Draft Mode version: live updates, client components services.ts+page.tsxThe paginated listing at /case-studies -
Config:
caseStudy: { title: "Case Study", contentType: "caseStudy", route: "/case-studies/[slug]", listing: "/case-studies", specialtyPage: "Case Studies Listing", body: "caseStudy", }, -
Contentful:
- a 📄 Case Study content type with
title,slug,pageBody(limited to the three components) andseo(→ 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
- a 📄 Case Study content type with
| 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:
- Create a Page in Contentful (for example, the title “Case Studies”).
- Set its Specialty Page to Case Studies Listing.
- Publish it.
Links to that Page now resolve to /case-studies.
4. Create one and preview it
pnpm dev
- In Contentful, create a Case Study entry with a title and a slug (for example
northwind), and add a Hero to its body. - The Live Preview pane opens
/case-studies/northwindin Draft Mode, and updates as you edit. - 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 runpnpm aces sync --contentfulto 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 topage.tsxwhere it should render. - Remove it:
pnpm aces page remove caseStudy, thenpnpm aces page-body remove caseStudy. Add--delete-content-typeto remove the type from the space as well.
Something wrong or missing? Open an issue.