Skip to content
Sign inJoin waitlist

Pages and sections — Cerette Astro

A page is a small file that picks sections and hands them content. src/pages/about.astro is the whole About page:

---
import AboutAwards from "../components/sections/AboutAwards.astro";
import AboutIntro from "../components/sections/AboutIntro.astro";
import AboutTeam from "../components/sections/AboutTeam.astro";
import CtaSection from "../components/sections/CtaSection.astro";
import QuoteSection from "../components/sections/QuoteSection.astro";
import about from "../content/pages/about.json";
import Layout from "../layouts/Layout.astro";
import { getTeam } from "../lib/content";
import { toTeamCard } from "../lib/to-ui";
const team = await getTeam();
---
<Layout title={about.meta.title} description={about.meta.description}>
<AboutIntro content={{ ...about.title, statement: about.statement }} figures={about.figures} />
<QuoteSection content={about.quote} half />
<AboutTeam content={about.team} people={team.map(toTeamCard)} />
<AboutAwards content={about.awards} />
<CtaSection fit half />
</Layout>
  • Layout (src/layouts/Layout.astro) gives the page its browser title, description, canonical link, share image and icons, the header and the footer.
  • Each section gets its copy from about.json; AboutTeam also gets the team from its collection. CtaSection reads its own copy (src/content/pages/cta.json); fit makes it as tall as its text, half makes it appear once half of it is in view.

Pages built from a collection read it through src/lib/content.ts (getProjects(), getServices(), getPosts(), …) and turn each item into what a card shows with src/lib/to-ui.ts (see Editing the content).

11 kinds of page and 32 addresses in the sitemap. 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, cta.json the first six projects, every service, every testimonial, the three newest posts
About /about src/pages/about.astro about.json, cta.json the team
Projects /project src/pages/project.astro projects.json, cta.json every project, every testimonial
Project /project/<slug> src/pages/project/[slug].astro project.json, cta.json one project, its services, three other projects
Services /service src/pages/service.astro services.json, forms.json every service
Service /service/<slug> src/pages/service/[slug].astro service.json, forms.json one service
Blog /blog src/pages/blog.astro blog.json (blogPage) every post, newest first
Post /blog/<slug> src/pages/blog/[slug].astro blog.json (postPage), cta.json one post, up to three more of its category
Contact /contact src/pages/contact.astro contact.json, forms.json —
Legal /legal/<slug> src/pages/legal/[slug].astro legal.json one legal page
404 any unknown address src/pages/404.astro not-found.json —

The addresses are the original design’s: the Projects page is /project, a project /project/<slug>, the Services page /service and a service /service/<slug>. Pages are built as files (about.html, project/aureline-house.html), which hosts serve at /about and /project/aureline-house (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).

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 Used on
HomeHero, HomeAbout, HomeProjects, HomeServices, HomeAchievement, HomeBlog Home
HomeWhy (“Why Cerette”) Home, Services
HomeTestimonials Home, Projects
AboutIntro, AboutTeam, AboutAwards About
ProjectsMain (with ProjectGrid) Projects
ProjectHero, ProjectInfo, ProjectStory Project
ServicesMain Services
ServiceMain Service
BlogList Blog
PostMain Post
ContactMain Contact
LegalMain Legal
NotFoundSection 404
QuoteSection (the founder’s quote) Home, About, Services
CtaSection (the call to action) Home, About, Projects, Project, Post
InquirySection (the photo, the heading and InquiryForm) Services, Service; InquiryForm alone on Contact
RelatedSection (“Other Work” with ProjectGrid, “Similar posts” with PostCards) Project, Post
RulerRow (the ruler between sections) most pages

Some parts are shared: PageTitle.astro (the big title with the small text beside it, the intro and the buttons) opens About, Projects, Services, Blog and Contact, with the room for the header from page-title.ts (pageTitleSpace); ProjectGrid lays out the project cards of Projects and “Other Work”.

Collections feed several pages at once, so changing an item there changes every page that shows it:

Block Comes from Shown on
The project cards projects.json Home (“Our Projects”, the first six), Projects, “Other Work” on a project page
The services services.json Home (the switcher), Services (the cards), the footer, a project’s Services, the service page’s form
The testimonials testimonials.json Home, Projects
The post cards posts.json Home (“Latest Insights”), Blog, “Similar posts” on a post
The footer’s Services and Legal links services.json, legal.json every page

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 founder’s quote quote in home.json, about.json, services.json Home, About, Services
“Why Cerette” why in home.json, services.json Home, Services
The figures about.figures, achievement.figures in home.json; figures in about.json Home, About
The awards achievement.awards in home.json; awards.rows in about.json Home, About
The testimonials’ heading testimonials in home.json, projects.json Home, Projects
The e-mail, phone and address contact in site.json; email, phone, address in contact.json the footer, Contact
“Book a call” the actions of home.json, about.json, projects.json, services.json Home, About, Projects, Services

The menu holds Home, About, Services, Projects and Blog, and the “Let’s talk” button (Contact); the logo leads Home. The other pages are reached like this:

Page Linked from
A project Its card (Home, Projects, “Other Work”)
A service Home’s switcher (“More details”), its card on Services, a project’s Services, the footer’s Services
A post Its card (Home, Blog, “Similar posts”)
A legal page The footer’s Legal column
Home, About, Services, Projects, Blog, Contact Also the footer’s Quick Links (footer.quickLinks in site.json), its “Contact us” and the buttons of the copy (“More about us”, “All Projects”, “All Articles”, “Our Services”…)

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 and the collections. Photos are the placeholders of the download.

Ten blocks, top to bottom, with rulers between some: the hero (the video under a dark veil, the label, the text, the title and two buttons); “About us” (three figures, the title, the text, three points, two buttons and a photo); “Our Projects”, the first six projects as cards; the founder’s quote over a photo; “Our Services”, the switcher; “Why Cerette”, a tall photo and six value cards; the call to action over a photo; the achievements (four figures, the awards table, three photos); “Client Experiences”, every testimonial; “Latest Insights”, the three newest posts. Their words are in src/content/pages/home.json (the call to action in cta.json); the cards and the switcher come from the collections.

Home: sections and the files behind them

Five blocks: the big title “Studio.” with the intro, two buttons, a photo, the statement and four figures; the founder’s quote; “Meet The Team” (one person at a time on desktops, cards on tablets and phones); “Our Achievements”, a photo and the awards table; the call to action. The words are in src/content/pages/about.json, the people in team.json.

About: sections and the files behind them

Three blocks and a ruler: the big title with the years beside it, the text, two buttons, then every project as a card; “Client Experiences”, every testimonial; the call to action. The words are in src/content/pages/projects.json, the projects in projects.json.

Projects: sections and the files behind them

The cover (the project’s photo, its category, title and summary, “(Scroll to explore)”); the facts (year, location, duration, area, services); the story (four photos around the overview, The Brief and Scope of Work, the result beside the gallery, the wide result photo); “Other Work”, the next three projects in the file’s order; the call to action. Everything but the labels (src/content/pages/project.json) is the project in projects.json.

Project: sections and the files behind them

The big title with the intro and two buttons, then every service as a card; “Why Cerette”; the founder’s quote; the inquiry block (a photo on desktops, the heading and the form). The words are in src/content/pages/services.json, the inquiry block in forms.json; the cards are services.json. This page has no entrance or scroll effects.

Services: sections and the files behind them

The label “Service”, the service’s name and summary over its wide photo, then “About service” and “What’s included” with the deliverables; the inquiry block, whose form starts with the service’s name in Project type. Everything but the labels (src/content/pages/service.json) and the inquiry block (forms.json) is the service in services.json.

Service: sections and the files behind them

One section: the big title “Articles.” with the text, then every post as a card, three per row on desktops: six at first (four on tablets and phones) and a page more each time the spinner under the grid comes near the window. The words are blogPage in src/content/pages/blog.json, the posts in posts.json.

Blog: sections and the files behind them

The article (the category, the title, the excerpt and the date, the photo, the content); “Similar posts”, up to three others of the same category; the call to action. Everything but the labels (postPage in src/content/pages/blog.json) is the post in posts.json.

Post: sections and the files behind them

One section: the title “Contact us.” with “(Start Your Project)”, the two paragraphs of the intro, the e-mail, phone, address and working hours, beside the inquiry form (Forms). The words and details are in src/content/pages/contact.json, the form in forms.json.

Contact: sections and the files behind them

One section: the title, “Last updated:” with the date, and the text. Everything but the label (src/content/pages/legal.json) is the page in legal.json.

Legal: sections and the files behind them

One section, one screen tall: a photo under a dark veil with “Error 404”, the subtitle, a line and a button back to Home. They are in src/content/pages/not-found.json.

Page not found: sections and the files behind them

Move the lines in the page file, or delete one (and its import). To take the testimonials off the home page, delete <HomeTestimonials … /> 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. <RulerRow /> lines are the rulers between sections: delete them with the section they separate.

The header turns the page colour once the section after Home’s hero (HomeAbout) reaches the middle of the window: that section carries headerSwitch. If you remove or move HomeAbout, give the Section that follows the hero headerSwitch instead (the header). On a project page ProjectInfo carries it.

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

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

    {
    "meta": {
    "title": "Careers",
    "description": "Join the studio: open roles in architecture, interior design and construction, and how we work together."
    },
    "title": "Careers.",
    "aside": "(Join the Studio)",
    "intro": "We’re always looking for curious architects, designers and builders."
    }
  3. Create src/pages/careers.astro:

    ---
    import PageTitle from "../components/sections/PageTitle.astro";
    import { pageTitleSpace } from "../components/sections/page-title";
    import careers from "../content/pages/careers.json";
    import Section from "../design-system/components/layout/Section.astro";
    import Layout from "../layouts/Layout.astro";
    ---
    <Layout title={careers.meta.title} description={careers.meta.description}>
    <Section class={pageTitleSpace}>
    <PageTitle title={careers.title} aside={careers.aside} intro={careers.intro} />
    </Section>
    </Layout>

    pageTitleSpace keeps the page from starting under the fixed header (the header). PageTitle gives the page its one <h1>.

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

  5. Add routes.careers to the pages list in src/pages/sitemap.xml.ts, next to the other top-level pages.

Delete its file under src/pages/ (for Projects, Services and Blog, 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 (the footer, for example, links every service and legal page). Links written as text in the content are not checked: the /project, /service, /blog and /contact of the buttons and the 404 page, for example. Search src/content/ for the path.

src/pages/blog/[slug].astro builds one page per post:

export async function getStaticPaths() {
return (await getPosts()).map((post) => ({ params: { slug: post.slug }, props: { post } }));
}

Add a post to src/content/collections/posts.json, and its page, its card and its sitemap entry appear on the next build; any other address under /blog/ is a 404. The same pattern builds the project, service and legal pages (src/pages/project/[slug].astro, service/[slug].astro, legal/[slug].astro). The testimonials and the team have no pages of their own.

src/pages/404.astro, with its copy 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.

  • One fixed bar at the top, 83 px tall from tablets up and 58 on phones. Inner pages give their first section pageTitleSpace, which takes the same room.
  • Over a dark cover (Home’s video, a project’s cover, the 404 photo) the bar is transparent, with the logo, the links and the menu button in white. On Home and a project page it turns the page colour, drawn in black, once the section marked headerSwitch reaches the middle of the window, and back above it. On every other page it is the page colour from the start.
  • Desktop and tablet: the logo on the left, the links in the middle, “Let’s talk” on the right. Phone: the logo and a menu button.
  • The phone menu. A press opens the bar under the logo to the links and the button, on white. It closes on Escape, on a link, on the button and when the window grows to tablet size. src/components/site/header.ts runs it.
  • The menu is navigation in src/content/site.json, the button headerAction. The link of the current page is Brown, and screen readers hear it as the current page.
  • Sitemap: src/pages/sitemap.xml.ts builds sitemap.xml from routes.ts and the collections: the six main pages (Home, About, Projects, Services, Blog, Contact), then every project, legal page (with its date), service and post (with its date): 32 addresses in the demo. The 404 page and the style guide are left out.
  • Robots: src/pages/robots.txt.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 src/layouts/Layout.astro (with src/lib/meta.ts). The pages with a file in src/content/pages/ write theirs in its meta; Home uses site.title. The pages built from a collection take theirs from the item: a project its title and summary, a service its name and summary, a post its title and excerpt, a legal page its title and first paragraph (a text under 80 characters is followed by the start of the next one). A title that would be longer than 60 characters with | Cerette appended is shown without the suffix. Posts are shared as articles, with their date and category. Every page shares the same image, public/opengraph-image.png.
  • Not indexed: the style guide and the 404 page (noindex).