Skip to content
Sign inJoin waitlist

Pages and sections — Kendi Next.js

A page is a small file that picks sections and hands them content. src/app/blog/page.tsx is the whole Articles page:

export const metadata = pageMeta(routes.blog, { title: meta.title, description: meta.description });
export default async function BlogPage() {
const [posts, categories, authors, photos] = await Promise.all([getPosts(), getCategories(), getAuthors(), getNewsletterPhotos()]);
return (
<>
<BreadcrumbSection items={[{ label: crumb }]} />
<BlogSection posts={toPostCards(posts, categories, authors)} />
<NewsletterSection photos={photos} />
</>
);
}
  • pageMeta(route, meta) gives the page its browser title, description, canonical link and share image.
  • getPosts() reads the collection, newest first (see Editing the content). toPostCards turns each post into what a card shows, with its category and author (src/lib/to-ui.ts).
  • The sections render them: the breadcrumb, the title and every post as a card, then the newsletter band.

11 kinds of page and 86 addresses in the demo. Every address is in src/content/routes.ts; the lists live at /category and /author, in the singular, so a category is /category/business and an author /author/olivia-bennett.

Page Address Page file Copy (src/content/pages/) Items it shows
Home / src/app/page.tsx home.ts posts, categories, authors
About /about src/app/about/page.tsx about.ts team
Articles /blog src/app/blog/page.tsx blog.ts posts
Post /blog/<slug> src/app/blog/[slug]/page.tsx post.ts one post, six of its category
Categories /category src/app/category/page.tsx categories.ts categories, two posts each
Category /category/<slug> src/app/category/[slug]/page.tsx category.ts one category, its posts
Authors /author src/app/author/page.tsx authors.ts authors, four posts each
Author /author/<slug> src/app/author/[slug]/page.tsx author.ts one author, their posts
Contact /contact src/app/contact/page.tsx contact.ts —
Legal page /legal/<slug> src/app/legal/[slug]/page.tsx legal.ts one legal page
404 any unknown address src/app/not-found.tsx not-found.ts —

To change an address, rename its folder in src/app/ and its entry in routes.ts, and search the content for the old address: links written as text aren’t checked (removing a page).

In src/components/sections/, one folder per page and the shared ones at the top. Each takes its copy from a page file (or site.ts) and its items from a collection.

Section File Used on
HeroSection (the slideshow, the list beside it, the newsletter box), HomeMainSection (the lists beside the sidebar) home/ Home
AboutMainSection, TeamSection about/ About
BlogSection (with PostGrid and the loader) blog/ Articles
PostMainSection (the article beside the sidebar), RelatedSection post/ Post
CategoryOverview, AuthorOverview taxonomy/ Categories, Authors
CategoryHead, AuthorHead (ArchiveHeads.tsx), ArchiveGrid (shared.tsx) taxonomy/ Category, Author
ContactSection contact/ Contact
LegalSection legal/ Legal
BreadcrumbSection BreadcrumbSection.tsx every page but Home and the 404
Sidebar Sidebar.tsx inside HomeMainSection and PostMainSection
NewsletterSection (the band above the footer) NewsletterSection.tsx every page but the legal pages and the 404

Some blocks have one copy that several pages read, so changing it once changes it everywhere:

Block Copy Shown on
The newsletter band: title, text, the form and its consent line, three photos newsletter in src/content/site.ts; the photos are the covers of the three newest posts every page but the legal pages and the 404
The sidebar: About, Explore Topics, the newsletter card, Spotlight, the ad sidebar, newsletter.form and sponsoredAd in site.ts; the categories and posts from the collections Home, every post
The sponsored ad sponsoredAd in site.ts Home (wide), the sidebar (tall)
The breadcrumb breadcrumbs in site.ts; each page’s last crumb in its page file every page but Home and the 404
The Categories menu categoriesMenu in site.ts; categories and trending posts from the collections the header of every page

The menu holds Home, Articles, Categories (a menu), About and Authors; the header’s button opens Contact. The other pages are reached like this:

Page Linked from
A post Its card everywhere (Home, Articles, a category or author page, Categories, Authors, Related Post, the Spotlights) and the newsletter band’s photos
A category The Categories menu, the sidebar’s Explore Topics, the footer’s Categories column, the pill on every card and the breadcrumb of a post
Categories “More categories” in the menu and the sidebar, “More” in the footer, the breadcrumb of a category page
An author The author’s name on every card and post, and Authors
Legal pages The footer’s legal links and the newsletter’s consent line (footer.legalLinks, newsletter.form.consent in site.ts)
Contact The header’s button, About’s “Contact us”, the sponsored ad’s “Learn more”

Every page type with each section outlined and labelled: the component that renders it, the file to edit, and where its copy (src/content/pages/*.ts, src/content/site.ts) and items (src/content/collections/*.ts) come from. Header and footer take their links and details from src/content/site.ts. Photos are the placeholders of the download. A section whose copy is in site.ts or that imports its own copy shows no copy line: the text below each map names it. A box labelled Section is the design system’s <Section> written in the page file itself (@/design-system, not a file in components/sections/), with the components it holds named under it.

Three sections, top to bottom: the hero (the slideshow of the five newest posts, the next three beside it, the eyebrow, title, lead and the newsletter box); the main column beside the sidebar (Editor’s pick, the wide sponsored ad, Trending, the Inspiration carousel and Latest posts with “View more”); the newsletter band. The words are in src/content/pages/home.ts, with the rules of every list (Editing the content); the sidebar and the ad are in site.ts.

Home: sections and the files behind them

Four sections: the breadcrumb; the story (the title, the lead, three photos, the statement, two paragraphs and “Contact us”); “Meet the Team” with every member of team.ts; the newsletter band. The words are in src/content/pages/about.ts.

About: sections and the files behind them

Three sections: the breadcrumb; every category (its photo, name, description and “View articles”) with its two newest posts under “From this category”; the newsletter band. The words are in src/content/pages/categories.ts, the categories in categories.ts.

Categories: sections and the files behind them

Three sections: the breadcrumb (Home > Categories > the category); the category’s name, description and photo over every post of the category, newest first (CategoryHead and ArchiveGrid in a <Section> of the page file); the newsletter band. Everything about the category is its entry in categories.ts; the patterns of its browser title and description are in src/content/pages/category.ts.

Category: sections and the files behind them

Three sections: the breadcrumb; every author (photo, name, role, bio, social links and “View articles”) with their four newest posts; the newsletter band. The words are in src/content/pages/authors.ts, the authors in authors.ts.

Authors: sections and the files behind them

Three sections: the breadcrumb (Home > Author > “Archives for” the name); the author’s photo, name, role, bio and social links over every post they wrote, newest first (AuthorHead and ArchiveGrid); the newsletter band. The author is their entry in authors.ts; the words are in src/content/pages/author.ts.

Author: sections and the files behind them

Three sections: the breadcrumb; the title and every post as a card, newest first, in columns (three on desktop, two on tablets, one on phones); the newsletter band. Six posts show at first, and six more load each time the end of the list comes into view (list.pageSize in src/content/pages/blog.ts). Every post is in the page’s HTML, so search engines find them all, and visitors without JavaScript see them all at once.

Articles: sections and the files behind them

Four sections: the breadcrumb (Home > the category > the title); the article (the title, the excerpt, the author and the cover across the page, then the category pill, the date and the text beside the sidebar); “Related Post” (the six newest other posts of its category, four on tablets and phones, and “View more”); the newsletter band. The article is the post in posts.ts; the labels are in src/content/pages/post.ts.

Post: sections and the files behind them

Two sections: the breadcrumb, then the title, “Last updated: “ with its date and the text. They are the legal page in src/content/collections/legal.ts; the label is in src/content/pages/legal.ts. The legal pages have no newsletter band. Their texts hold placeholders to fill in (Editing the content).

Legal page: sections and the files behind them

Three sections: the breadcrumb; the title, the lead and the details (address, e-mail and phone, business hours, social links) beside the contact form; the newsletter band. The words and the form are in src/content/pages/contact.ts (Forms); the details are contact and socials in src/content/site.ts.

Contact: sections and the files behind them

One block, a screen tall: the big “404”, a title, a line and a button back to Home. They are in src/content/pages/not-found.ts; the layout is written in src/app/not-found.tsx.

Page not found: sections and the files behind them

Move the lines in the page file, or delete one. To take the newsletter band off About, delete <NewsletterSection … /> from src/app/about/page.tsx. Removing a shared block from one page leaves it on the others (shared blocks).

The blocks of Home’s main column (Editor’s pick, the ad, Trending, Inspiration, Latest posts) are parts of one section: move or delete them in src/components/sections/home/HomeMainSection.tsx. The sidebar’s blocks (About, Explore Topics, the newsletter card, Spotlight, the ad) are in src/components/sections/Sidebar.tsx.

  1. Add the URL to src/content/routes.ts:

    advertise: "/advertise",
  2. Add its copy to src/content/pages/advertise.ts, with a meta (title, description):

    export const meta = {
    "title": "Advertise With Us",
    "description": "Reach curious readers: sponsored posts, the sidebar ad and newsletter placements on Kendi.",
    };
    export const crumb = "Advertise";
    export const title = "Advertise with us";
    export const lead = "Put your brand in front of readers who value depth and context.";
  3. Create src/app/advertise/page.tsx:

    import { BreadcrumbSection } from "@/components/sections/BreadcrumbSection";
    import { NewsletterSection } from "@/components/sections/NewsletterSection";
    import { crumb, lead, meta, title } from "@/content/pages/advertise";
    import { routes } from "@/content/routes";
    import { Section, cn, text } from "@/design-system";
    import { pageMeta } from "@/lib/meta";
    import { getNewsletterPhotos } from "@/lib/sidebar";
    export const metadata = pageMeta(routes.advertise, { title: meta.title, description: meta.description });
    export default async function AdvertisePage() {
    const photos = await getNewsletterPhotos();
    return (
    <>
    <BreadcrumbSection items={[{ label: crumb }]} />
    <Section inner="flex flex-col gap-5">
    <h1 className={text.h3}>{title}</h1>
    <p className={cn(text.body, "max-w-[700px] text-grey")}>{lead}</p>
    </Section>
    <NewsletterSection photos={photos} />
    </>
    );
    }

    The page starts under the header by itself: the header is fixed and keeps a spacer of its height (the header).

  4. Link to it: add { "label": "Advertise", "href": "/advertise" } to navigation in src/content/site.ts (the menu), or to a column of footer.columns. Pointing the sponsored ad’s cta.href at it makes the ad an “advertise with us” link.

  5. Add routes.advertise to the paths list in src/app/sitemap.ts, next to the other top-level pages.

Delete its folder under src/app/, its entry in navigation and the footer’s links (src/content/site.ts), its line in src/app/sitemap.ts, and the route in routes.ts. npm run build then tells you about anything still using the route through routes. Links written as text in the content are not checked: the header’s “Contact us”, About’s button and the ad’s “Learn more” (/contact), the “More categories” links (/category), the “View more” links (/blog) and the footer’s columns, for example. Search src/content/ for the path.

src/app/blog/[slug]/page.tsx builds one page per post:

export const dynamicParams = false; // only the slugs below exist; anything else is a 404
export async function generateStaticParams() {
return (await getPosts()).map((post) => ({ slug: post.slug }));
}

Add a post to src/content/collections/posts.ts, and its page, its cards and its sitemap entry appear on the next build. The same pattern builds the category pages, the author pages and the legal pages. A slug may hold a character such as the typographic ’ (three demo posts do): the address encodes it.

src/app/not-found.tsx, with its copy in src/content/pages/not-found.ts. Next.js shows it for any unknown address, and for a post, category, author or legal slug that doesn’t exist, with a 404 status and noindex, like the style guide.

  • A white bar fixed at the top of every page, 65 px tall on phones and 82 px from tablets up. A spacer of the same height sits under it, so pages start below it (src/components/site/Header.tsx).
  • Desktop: the logo, the menu links and the “Contact us” button. Hovering Categories opens a panel with the first five categories (photo, name, description), “More categories” and the Spotlight (the first four trending posts). Tablet and phone: the logo and a menu button; the menu opens under the bar with the links, the categories in a list that opens under Categories, and the button. It closes when a link is followed or the visitor presses Escape.
  • The menu is navigation in src/content/site.ts, the button headerAction, the panel categoriesMenu. On hover a link’s label rolls up.
  • Sitemap: src/app/sitemap.ts builds sitemap.xml from routes.ts and the collections: Home, About, Contact, Articles, Categories and every category, Authors and every author, every post and the legal pages — 86 addresses in the demo. The 404 page and the style guide are left out.
  • Robots: src/app/robots.ts builds robots.txt, which allows everything and points at the sitemap. Both use site.url, so set your domain before publishing.
  • Per page: every indexable page gets a title, a description, a canonical link, an og:url and a share image from pageMeta (src/lib/meta.ts). The pages with one address write theirs in their page file’s meta. The pages built from a collection fill a pattern from the item: a post its title and excerpt, a category its name and description, an author their profile, a legal page its title. A title that would be longer than 60 characters with | Kendi appended is shown without the suffix. Posts share their own cover, as articles with their date; categories and authors share their photo.
  • Not indexed: the style guide and the 404 page (noindex).