Pages and sections — Lookis Astro
A page is a small file that picks sections and hands them content. src/pages/about.astro is the whole About page:
---import AboutSection from "../components/sections/AboutSection.astro";import ShowcaseSection from "../components/sections/ShowcaseSection.astro";import about from "../content/pages/about.json";import shared from "../content/pages/shared.json";import siteContent from "../content/site.json";import Layout from "../layouts/Layout.astro";
const { meta, ...content } = about;---
<Layout title={meta.title} description={meta.description}> <AboutSection {...content} socials={siteContent.socials} /> <ShowcaseSection {...shared.showcase} tinted /></Layout>Layout(src/layouts/Layout.astro) gives the page its browser title, description, canonical link, share image and icons, the header and the footer.AboutSectiongets the page’s copy fromabout.jsonand the social links fromsite.json.ShowcaseSectionis the “See what I do” band above the footer, read fromshared.json;tintedgives it the light grey fill it has on About and Contact.
Pages built from a collection read it through src/lib/content.ts (getProjects(), getServices(), …) and turn each
item into what a card shows with src/lib/to-ui.ts (see Editing the content).
The pages
Section titled “The pages”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/pages/index.astro |
home.json, shared.json |
the first six projects, every service |
| About | /about |
src/pages/about.astro |
about.json, shared.json |
— |
| Portfolio | /portfolio |
src/pages/portfolio.astro |
portfolio.json (portfolioPage), shared.json |
every project, a tab per service |
| Project | /portfolio/<slug> |
src/pages/portfolio/[slug].astro |
portfolio.json (projectPage) |
one project, its service’s name, up to three related projects |
| Services | /services |
src/pages/services/index.astro |
services.json (servicesPage), shared.json |
every service |
| Service | /services/<slug> |
src/pages/services/[slug].astro |
services.json (servicePage), shared.json |
one service, three others |
| Contact | /contact |
src/pages/contact.astro |
contact.json, shared.json |
— |
| 404 | any unknown address | src/pages/404.astro |
not-found.json |
— |
Pages are built as files (about.html, portfolio/downtown-vows.html), which hosts serve at /about and
/portfolio/downtown-vows (Going live). To change an address, rename its file in src/pages/
(and its folder, for the pages built from a collection) and its entry in routes.ts, and search the content for the old
address: links written as text aren’t checked (removing a page).
The sections you can use
Section titled “The sections you can use”In src/components/sections/, one file per section. Each takes its copy from a page file (or site.json) and its
items from a collection.
| Section | File | Used on |
|---|---|---|
HomeHeroSection, HomeAboutSection, HomeProjectsSection, HomeFactsSection, HomeServicesSection |
one file each | Home |
TestimonialsSection |
TestimonialsSection.astro |
Home, Services, Service |
ShowcaseSection |
ShowcaseSection.astro |
Home, About (tinted), Portfolio, Services, Service, Contact (tinted, gallery only) |
AboutSection (with ProfileHeading, SocialLinks, ColumnDivider) |
AboutSection.astro and the three parts |
About |
PortfolioSection (with PortfolioProjects) |
PortfolioSection.astro, PortfolioProjects.astro, portfolio.ts |
Portfolio |
ProjectSection, RelatedProjectsSection |
one file each | Project |
ServicesIntroSection, ServicesQuestionsSection |
one file each | Services |
ServiceDetailSection |
ServiceDetailSection.astro |
Service |
ContactSection |
ContactSection.astro |
Contact |
NotFoundSection |
NotFoundSection.astro |
404 |
Some parts are shared between sections: ProfileHeading.astro (the label, the square portrait and the page title) and
SocialLinks.astro open both About and Contact; PortfolioProjects.astro holds Portfolio’s tabs, cards and spinner,
whose shapes are in portfolio.ts. The two-column layout of About, Services, a service, Contact and a project (the photo
on the left, the text on the right) is SplitLayout from the design system.
Blocks that appear on several pages
Section titled “Blocks that appear on several pages”Two bands come from one file, src/content/pages/shared.json, so changing them there changes every page that shows them:
| Block | Field | Shown on |
|---|---|---|
| The testimonials: the photo, the heading, the slideshow | testimonials in shared.json |
Home, Services, every service page |
| “See what I do”: the heading, “Contact me”, the five photos and the Instagram button | showcase in shared.json |
Home, About, Portfolio, Services, every service page, Contact (the photos and the button only) |
| The social links | socials in site.json |
the Home hero, About, Contact, the footer |
Other blocks are written in each page’s file, so a page can say something different; to change one everywhere, change it in every file that has it:
| Block | Field | Shown on |
|---|---|---|
| The four numbers | facts.items in home.json (with a line under each) and facts in about.json (without) |
Home (“My numbers”), About |
| “Selected Projects” and its title | projects.intro in home.json, portfolioPage.intro in portfolio.json |
Home, Portfolio |
| “My Services” and its title | services.intro in home.json, servicesPage.intro in services.json |
Home, Services |
| The photographer’s portrait and photos | hero.image in home.json, footer.image in site.json, contact.intro.portrait in contact.json (the same file, hero.jpg, in the demo); about.images in home.json and the photos of about.json share files too |
Home, the footer, Contact, About |
How the pages link to each other
Section titled “How the pages link to each other”The menu holds Portfolio, About, Services and Contact; the logo leads Home. The other pages are reached like this:
| Page | Linked from |
|---|---|
| A project | Its card (Home’s “Selected Projects”, Portfolio, “Related Projects” at the end of another project) |
| A service | Its row on Home, its card on Services, “Other Services” at the end of another service page |
| Home, Portfolio, Services, About, Contact | Also the footer’s Quick Links (footer.quickLinks in site.json) and the buttons of the copy (“See my portfolio”, “Learn about me”, “See my service”, “Contact me”…) |
Page maps
Section titled “Page maps”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/*.json, src/content/site.json) and items (src/content/collections/*.json) come from.
Header and footer take their links and details from src/content/site.json. 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, two buttons
and the social links); “About me” with four photos; “Selected Projects”, the first six projects (projects.count);
“My numbers” with a photo; “My Services”, every service as a row; the testimonials; “See what I do”. Their words are in
src/content/pages/home.json, apart from the testimonials and “See what I do”, which are in shared.json.

Two sections. The first holds the page photo on the left (it stays in place while the text scrolls on tablets and
desktops) and three blocks on the right: the label with the portrait, the title and the social links; “My little story”
with two photos, three paragraphs, a button and the four numbers; “Awards & Recognitions”, the award cards with a photo
after the third. The second is “See what I do” on a light grey fill. The words, numbers and awards are in src/content/pages/about.json.

Portfolio
Section titled “Portfolio”Two sections. The first holds the heading, the filter tabs (“All”, then one per service, in the order of
services.json) and every project as a card, two per row (one on phones): four at first, then four more each time the
spinner under the list comes within about 500 px of the screen. A tab shows the projects of its service and starts again
at four. The second is “See what I do”. The words are in portfolioPage in src/content/pages/portfolio.json, the projects in portfolio.json.

Project
Section titled “Project”Two sections: the project (its main photo on the left, staying in place on tablets and desktops; on the right the
title, the summary, the date and the service, “Overview” and the details, and “Project Gallery” with every photo of its
gallery, one under the other) and “Related Projects”: up to three other projects of the same service, in the order of
the file (two on tablets); the section is left out when there are none. Everything but the headings is the project in
portfolio.json; the headings are projectPage in src/content/pages/portfolio.json. A project page has no “See what I
do” band.

Services
Section titled “Services”Four sections: the page photo on the left and on the right the heading, two paragraphs and every service as a card (its
name, summary, price and an arrow); “Questions”, six questions that open one by one; the testimonials; “See what I do”.
The heading, the photo and the questions are servicesPage in src/content/pages/services.json; the cards are
services.json.

Service
Section titled “Service”Three sections: the service (its photo on the left; on the right its name above its summary as the title, the price,
the text, “Schedule a call”, “Perfect for” and “What’s Included” as numbered lists, and “Other Services”, the three other
services as cards); the testimonials; “See what I do”. Everything in the first section is the service in
services.json, apart from the headings and the button (servicePage in src/content/pages/services.json) and the
button’s link (bookingHref in site.json).

Contact
Section titled “Contact”Two sections: the page photo on the left and on the right the label with the portrait, the title, three paragraphs, the
social links and the contact form in a light card (Forms); then the five photos of “See what I do” and the
Instagram button on a light grey fill. The words and the form are in src/content/pages/contact.json. The e-mail and
phone number are in the footer, from contact in src/content/site.json.

Page not found
Section titled “Page not found”One section: a photo as tall as the window with a dark gradient, “404”, a title, a button back to Home and a link to
Portfolio. They are in src/content/pages/not-found.json.

Reordering or removing a section
Section titled “Reordering or removing a section”Move the lines in the page file, or delete one (and its import). To take the numbers off the home page, delete
<HomeFactsSection … /> from src/pages/index.astro; its copy in src/content/pages/home.json can stay or go, as every
page reads only its own file. To leave “See what I do” off a page, delete its <ShowcaseSection … /> line.
A few blocks are parts of a bigger section, so they go inside its file: the awards and “My little story” are parts of
AboutSection.astro (each between <ColumnDivider /> lines), the questions of Services are ServicesQuestionsSection,
and the lists of a service page (“Perfect for”, “What’s Included”, “Other Services”) are blocks of
ServiceDetailSection.astro.
Adding a page
Section titled “Adding a page”-
Add the URL to
src/content/routes.ts:journal: "/journal", -
Add its copy to
src/content/pages/journal.json, with ameta(title, description):{"meta": {"title": "Journal","description": "Notes from the road and behind the camera: the stories, places and light behind my favourite photographs."},"intro": {"label": "Journal","title": "Notes from the road and behind the camera.","text": "Short stories about the places, people and light behind the photographs."}} -
Create
src/pages/journal.astro:---import ShowcaseSection from "../components/sections/ShowcaseSection.astro";import journal from "../content/pages/journal.json";import shared from "../content/pages/shared.json";import Section from "../design-system/components/layout/Section.astro";import SectionIntro from "../design-system/components/layout/SectionIntro.astro";import { text } from "../design-system/tokens/text";import Layout from "../layouts/Layout.astro";---<Layout title={journal.meta.title} description={journal.meta.description}><Section><SectionIntro as="h1" label={journal.intro.label} title={journal.intro.title} titleClass={text.h1} lead={journal.intro.text} align="center" /></Section><ShowcaseSection {...shared.showcase} /></Layout>The page starts under the header by itself: the header is sticky and takes its own room (the header). Give the title
as="h1": every page has one<h1>. -
Link to it: add
{ "label": "Journal", "href": "/journal" }tonavigationinsrc/content/site.json(the menu), and tofooter.quickLinksif you want it in the footer. -
Add
routes.journalto thepageslist insrc/pages/sitemap.xml.ts, next to the other top-level pages.
Removing a page
Section titled “Removing a page”Delete its file under src/pages/ (for Portfolio and Services, also the folder of their item pages), its entry in
navigation and the footer’s Quick Links (src/content/site.json), its line in src/pages/sitemap.xml.ts, and the route
in routes.ts. npm run check 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, the 404 page
and the footer’s Quick Links, for example. Search src/content/ for the path.
Pages built from a collection
Section titled “Pages built from a collection”src/pages/portfolio/[slug].astro builds one page per project:
export async function getStaticPaths() { return (await getProjects()).map((project) => ({ params: { slug: project.slug }, props: { project } }));}Add a project to src/content/collections/portfolio.json, and its page, its card and its sitemap entry appear on the next
build; any other address under /portfolio/ is a 404. The same pattern builds the service pages
(src/pages/services/[slug].astro).
The 404 page
Section titled “The 404 page”src/pages/404.astro, with its copy and photo in src/content/pages/not-found.json. It is built as 404.html, which
hosts serve for any unknown address, with a 404 status; it is noindex, like the style guide.
The header
Section titled “The header”- Sticky. The header stays at the top of every page while the visitor scrolls, in the page colour. It is 70 px tall on phones and 95 px from tablets up, and takes its own room, so every page starts under it. The 1 px line under it is part of the page and scrolls away. Nothing about the header changes as the page scrolls.
- Desktop: the place and the live clock on the left (
ownerinsrc/content/site.json), the logo in the middle, the links on the right. Tablet: the logo on the left, the links on the right, no clock. Phone: the logo and a menu button of two lines. - The phone menu. A press turns the button’s lines into a cross and grows the bar over the page, with the links and
the place and clock under them. It closes on a press anywhere in the open bar (a link included), on Escape and when the
window grows to tablet width.
src/components/site/header.tsruns it. - The clock shows the time in
owner.timeZone, not the visitor’s own, besideowner.place(src/components/site/Clock.astro,clock.ts). It is empty in the HTML and filled as the page loads. - The menu is
navigationinsrc/content/site.json. The link of the current page looks like the others; screen readers hear it as the current page (a project or service page marks no link).
Search engines
Section titled “Search engines”- Sitemap:
src/pages/sitemap.xml.tsbuildssitemap.xmlfromroutes.tsand 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/pages/robots.txt.tsbuildsrobots.txt, which allows everything and points at the sitemap. Both usesite.url, so set your domain before publishing. - Per page: every indexable page gets a title, a description, a canonical link, an
og:urland a share image fromsrc/layouts/Layout.astro(withsrc/lib/meta.ts). The pages with a file insrc/content/pages/write theirs in itsmeta(a title of at most 60 characters and a description of 80 to 160: the demo’s are); Home usessite.titlewhen itsmeta.titleis the same. 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 text). A title that would be longer than 60 characters with| Lookisappended is shown without the suffix. Every page shares the same image,public/opengraph-image.png. - Not indexed: the style guide and the 404 page (
noindex).