Skip to content
Sign inJoin waitlist

Pages and sections — Lookis Next.js

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

export const metadata = pageMeta(routes.services, servicesPage.meta);
export default async function ServicesPage() {
const services = await getServices();
return (
<>
<ServicesIntroSection content={servicesPage.intro} services={services.map(toServiceCard)} />
<ServicesQuestionsSection content={servicesPage.questions} />
<TestimonialsSection content={testimonials} />
<ShowcaseSection content={showcase} />
</>
);
}
  • pageMeta(route, meta) gives the page its browser title, description, canonical link and share image.
  • getServices() reads the collection (see Editing the content). toServiceCard turns each service into what a card shows (src/lib/to-ui.ts).
  • The sections render them: the page photo with the title and every service as a card, the questions, the testimonials and “See what I do”.

8 kinds of page and 25 addresses in the demo. Every address is in src/content/routes.ts.

Page Address Page file Copy (src/content/pages/) Items it shows
Home / src/app/page.tsx home.ts, shared.ts the first six projects, every service
About /about src/app/about/page.tsx about.ts, shared.ts —
Portfolio /portfolio src/app/portfolio/page.tsx portfolio.ts, shared.ts every project, a tab per service
Project /portfolio/<slug> src/app/portfolio/[slug]/page.tsx portfolio.ts (projectPage) one project, its service’s name, up to three related projects
Services /services src/app/services/page.tsx services.ts, shared.ts every service
Service /services/<slug> src/app/services/[slug]/page.tsx services.ts (servicePage), shared.ts one service, three others
Contact /contact src/app/contact/page.tsx contact.ts, shared.ts —
404 any unknown address src/app/not-found.tsx not-found.ts —

The style guide (/style-guide, src/app/style-guide/) is a page too, for you: it is hidden from search engines and linked from nowhere.

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 file each. Each takes its copy from a page file (or site.ts) and its items from a collection.

Section Used on
HomeHeroSection, HomeAboutSection, HomeProjectsSection, HomeFactsSection, HomeServicesSection Home
TestimonialsSection Home, Services, Service
ShowcaseSection (“See what I do”) Home, About, Portfolio, Services, Service, Contact (gallery only)
AboutSection About
PortfolioSection (with PortfolioProjects, the tabs and the cards) Portfolio
ProjectSection, RelatedProjectsSection Project
ServicesIntroSection, ServicesQuestionsSection Services
ServiceDetailSection Service
ContactSection Contact
NotFoundSection 404

ProfileHeading (the label with the small portrait, the page title and what follows) is the top of AboutSection and ContactSection, and its file also holds the social links’ row (SocialLinks).

Two blocks have one copy that several pages read, so changing it once changes it everywhere. Their copy is in src/content/pages/shared.ts:

Block Export in shared.ts Shown on
The testimonials: the photo, the heading and the slideshow of quotes testimonials Home, Services, every service page
“See what I do”: the heading, “Contact me”, five photos and the Instagram button showcase Home, About, Portfolio, Services, every service page; Contact shows the photos and the button only

On About and Contact the “See what I do” band has a faint grey fill (tinted on <ShowcaseSection>), and on Contact the heading is left out (galleryOnly). To give a page its own words for one of these blocks, pass it an object of your own instead of the shared one, with the same fields: <ShowcaseSection content={myShowcase} />.

The social links (socials in src/content/site.ts) are shared the same way: the Home hero, About, Contact and the footer list them.

The menu holds Portfolio, About, Services and Contact; the logo leads home. The other pages are reached like this:

Page Linked from
Home The logo and the footer’s Quick Links
A project Its card: Home’s “Selected Projects”, Portfolio and “Related Projects”
A service Its row on Home, its card on Services and under “Other Services”
Portfolio The menu, “See my portfolio” (Home hero, 404), “View my portfolio” (Home)
About The menu, “Learn about me” (Home)
Services The menu, “See my service” (About)
Contact The menu, “Contact me” (Home, “See what I do”, the footer)

A project page names its service as plain text, not as a link, as in the original design.

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.

Seven sections, top to bottom: the hero (the name running across the top, the photo with the introduction, the two buttons and the social links); “About me” with four photos; “Selected Projects” (the first six projects: projects.count); “My numbers” with a tall photo; “My Services” (every service as a row with its photo and price); the testimonials; “See what I do”. The words are in src/content/pages/home.ts, except the testimonials and “See what I do” (shared blocks).

Home: sections and the files behind them

Two sections: the page itself (the photo on the left, which stays in view as you scroll from tablets up; on the right “About me” with the small portrait and the title, the social links, “My little story” with two photos, the four numbers, and “Awards & Recognitions” with a photo after the third award) and “See what I do”. The words are in src/content/pages/about.ts.

About: sections and the files behind them

Two sections: the heading, the filter tabs (All, then one per service) and the project cards, four at a time; then “See what I do”. The words are in src/content/pages/portfolio.ts (portfolioPage), the cards come from portfolio.ts and the tabs from services.ts.

Portfolio: sections and the files behind them

Two sections: the project (the main photo on the left; on the right the title, the summary, the date and the service, “Overview” and “Project Gallery”) and “Related Projects”, up to three other projects of the same service. The fixed words are projectPage in src/content/pages/portfolio.ts; everything else is the project’s own entry in src/content/collections/portfolio.ts.

Project: sections and the files behind them

Four sections: the page photo with the heading, two paragraphs and every service as a card with its price; “Questions”, six questions that open one by one; the testimonials; “See what I do”. The words are servicesPage in src/content/pages/services.ts.

Services: sections and the files behind them

Three sections: the service (its photo on the left; on the right its name, its summary as the title, the price, the content, “Schedule a call”, “Perfect for”, “What’s Included” and “Other Services”, three other services as cards), the testimonials and “See what I do”. The fixed words are servicePage in src/content/pages/services.ts; everything else is the service’s own entry in src/content/collections/services.ts.

Service: sections and the files behind them

Two sections: the page (the photo on the left; on the right “Contact Me” with the small portrait and the title, three paragraphs, the social links and the form card) and the “See what I do” photos without their heading. The words and the form are in src/content/pages/contact.ts (Forms).

Contact: sections and the files behind them

One section: a photo as tall as the window with “404”, the title and two buttons, “Back to Homepage” and “See my portfolio”. The words and the photo are in src/content/pages/not-found.ts.

404: sections and the files behind them

Move the lines in the page file, or delete one. To take the numbers off the home page, delete <HomeFactsSection … /> from src/app/page.tsx; its copy in src/content/pages/home.ts can stay or go.

A few blocks are parts of a bigger section, so they go inside its file: the awards and the story of About (in AboutSection.tsx), the form card of Contact (ContactSection.tsx), “Perfect for”, “What’s Included” and “Other Services” of a service page (ServiceDetailSection.tsx) and the gallery of a project page (ProjectSection.tsx).

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

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

    import type { SectionIntro } from "../types";
    export const journalPage = {
    meta: {
    title: "Journal",
    description: "Notes from the road and behind the camera: the stories behind a few favourite photographs.",
    },
    intro: {
    label: "Journal",
    title: "Notes from behind the camera.",
    text: "Short stories about light, places and the people in front of the lens.",
    } as SectionIntro,
    };
  3. Create src/app/journal/page.tsx:

    import { ShowcaseSection } from "@/components/sections/ShowcaseSection";
    import { journalPage } from "@/content/pages/journal";
    import { showcase } from "@/content/pages/shared";
    import { routes } from "@/content/routes";
    import { Section, SectionIntro, text } from "@/design-system";
    import { pageMeta } from "@/lib/meta";
    export const metadata = pageMeta(routes.journal, journalPage.meta);
    export default function JournalPage() {
    return (
    <>
    <Section>
    <SectionIntro as="h1" label={journalPage.intro.label} title={journalPage.intro.title} lead={journalPage.intro.text} titleClassName={text.h1} />
    </Section>
    <ShowcaseSection content={showcase} />
    </>
    );
    }

    The page starts under the sticky header by itself. Give every page one <h1>: here the title of SectionIntro (as="h1").

  4. Link to it: add { label: "Journal", href: "/journal" } to navigation in src/content/site.ts (the menu), and to footer.quickLinks if you want it in the footer.

  5. Add routes.journal to the pages 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 Quick Links (src/content/site.ts), its entry in the pages list of 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 /portfolio, /about, /services and /contact of the buttons, and the footer’s Quick Links, for example. Search src/content/ for the path.

src/app/services/[slug]/page.tsx builds one page per service:

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

Add a service to src/content/collections/services.ts, and its page, its row, its card, its Portfolio tab and its sitemap entry appear on the next build. The same pattern builds the project pages (src/app/portfolio/[slug]/page.tsx).

src/app/not-found.tsx, with its copy and photo in src/content/pages/not-found.ts. Next.js shows it for any unknown address, and for a project or service slug that doesn’t exist, with a 404 status and noindex, like the style guide. It has no “See what I do” band, as in the original design.

  • Sticky, and the same on every page. The header stays at the top of the page in the page colour while the visitor scrolls; nothing about it changes with scrolling. It is 70 px tall on phones and 95 px from tablets up. The 1px line under it belongs to the page and scrolls away.
  • Desktop: the town and the clock on the left (owner in src/content/site.ts), the logo in the middle, the links on the right. Tablet: the logo on the left and the links on the right, without the clock. Phone: the logo and a menu button.
  • The clock shows the time in owner.timeZone (America/New_York in the demo), the time zone of the town beside it, not the visitor’s own time. It is drawn in the browser once the page has loaded (src/components/site/Clock.tsx).
  • The menu is navigation in src/content/site.ts. The link of the current page looks like the others; screen readers hear it as the current page. On phones the menu button’s lines meet and cross into an X, and the bar grows over the page with the links and the clock; it closes when a link or the bar is tapped, when the visitor presses Escape, when the page changes and when the window grows to tablet width.
  • Sitemap: src/app/sitemap.ts builds sitemap.xml from routes.ts and the collections: the five main pages (Home, About, Portfolio, Services, Contact), then every project (with its date) and every service: 25 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 the share image from pageMeta (src/lib/meta.ts). The pages with a file in src/content/pages/ write theirs in its meta (a title of at most 60 characters and a description of 80 to 160: the demo’s are); Home’s title is used as it is, without the suffix. The pages built from a collection take theirs from the item: a project its title and summary, a service its name and summary; a summary under 80 characters is followed by the start of the overview or the content. A title that would be longer than 60 characters with | Lookis appended is shown without the suffix.
  • One <h1> per page: on Home it is the photographer’s name (the ticker is decoration, so the name is also written once for screen readers and search engines).
  • Not indexed: the style guide and the 404 page (noindex).