Skip to content
Sign inJoin waitlist

Pages and sections — Metuo Astro

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

---
import CtaSection from "../components/sections/CtaSection.astro";
import PageTitleSection from "../components/sections/PageTitleSection.astro";
import TestimonialStoriesSection from "../components/sections/TestimonialStoriesSection.astro";
import shared from "../content/pages/shared.json";
import testimonial from "../content/pages/testimonial.json";
import Layout from "../layouts/Layout.astro";
import { getTestimonials } from "../lib/content";
import { toTestimonialCard } from "../lib/to-ui";
const stories = (await getTestimonials()).map((item) => toTestimonialCard(item, testimonial.outcomesLabel));
const { clientRatings, ctaBand, questionLine, socialLinks } = shared;
---
<Layout title={testimonial.meta.title} description={testimonial.meta.description}>
<PageTitleSection title={testimonial.pageTitle.title} lead={testimonial.pageTitle.lead} image={testimonial.pageTitle.image} />
<TestimonialStoriesSection stories={stories} label={testimonial.storiesLabel} />
<CtaSection content={ctaBand} ratings={clientRatings} question={questionLine} socials={socialLinks} />
</Layout>
  • Layout (src/layouts/Layout.astro) gives the page its browser title, description, canonical link, share image and icons, the header and the footer.
  • PageTitleSection is the big photo with the page’s title, read from testimonial.json.
  • TestimonialStoriesSection gets every client story from the collection, through src/lib/content.ts (getTestimonials()), turned into what a card shows by src/lib/to-ui.ts.
  • CtaSection is the call to action band, read from shared.json.

9 kinds of page and 20 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, pricing.json, faq.json, book.json the first four services, the first four stories, the first three posts; every service as a checkbox
About /about src/pages/about.astro about.json, shared.json every team member
Services /service src/pages/service.astro service.json, shared.json, pricing.json, faq.json, book.json every service
Client Stories /testimonial src/pages/testimonial.astro testimonial.json, shared.json every client story
Journal /blog src/pages/blog.astro blog.json, shared.json every post
Post /blog/<slug> src/pages/blog/[slug].astro post.json, faq.json one post, up to three of its category
Contact /contact src/pages/contact.astro contact.json, book.json, faq.json, shared.json every service as a checkbox
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 (/service, /testimonial, /blog), while the menu calls them Services, Stories and Journal. Pages are built as files (about.html, blog/how-self-awareness-shapes-daily-growth.html), which hosts serve at /about and /blog/how-self-awareness-shapes-daily-growth (Going live). To change an address (/service to /services, say), 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 File Used on
HomeHeroSection, HomeAboutSection, HomeServiceSection, HomeWhySection, HomeStepSection, HomeStoriesSection one file each Home
PageTitleSection PageTitleSection.astro About, Services, Client Stories, Journal
FounderQuoteSection FounderQuoteSection.astro Home, About, Services
CtaBandSection CtaBandSection.astro inside Home’s “Why choose us” and About’s “Meet the team”
CtaSection (the band on its own) CtaSection.astro Client Stories, Journal
PricingSection PricingSection.astro Home, Services
VideoSection VideoSection.astro Home, About
BlogSection BlogSection.astro Home (“Our journal”), Post (“More insights for you.”)
FaqSection FaqSection.astro Home, Services, Contact, Post
BookSection BookSection.astro Home, Services, Contact (page: the page’s main section)
AboutVisionSection, AboutValueSection, AboutTeamSection one file each About
ServiceMainSection ServiceMainSection.astro Services
TestimonialStoriesSection TestimonialStoriesSection.astro Client Stories
BlogListSection BlogListSection.astro Journal
PostArticleSection PostArticleSection.astro Post
LegalArticleSection LegalArticleSection.astro Legal
NotFoundSection NotFoundSection.astro 404

Two parts are shared between sections: SectionIntro.astro (the “// label”, the title and the lead text of most sections) and QuestionLine.astro (the “send us an email” sentence of the call to action band and the booking section). The call to action band sits inside the section before it on Home and About (it is passed in the section’s slot), as in the original design.

Several blocks come from one file, so changing them there changes every page that shows them:

Block Field Shown on
The founder quote: the photo, the quote, the portrait, name and role founderQuote in shared.json Home, About, Services
The call to action band “Ready to take the first step…” with the trust line, the client ratings, the e-mail line and the social icons ctaBand, clientRatings, questionLine, socialLinks in shared.json Home, About, Client Stories, Journal
The plans pricing.json Home, Services
The questions and “Still have questions?” faq.json Home, Services, Contact, every post
The booking section and its form book.json (the trust line, ratings, e-mail line and icons from shared.json) Home, Services, Contact
The menu and “Book a session” navigation, bookLink in site.json the header, the phone menu, 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 stats in home.json and facts in service.json Home (under the stories), Services
The journal’s heading blogIntro in home.json, and post.json Home, every post
The video video.src in home.json and in about.json Home, About
The social links socials in site.json (the footer’s text links) and socialLinks in shared.json (the icons) the footer; the call to action band and the booking section
Your e-mail contact.email in site.json, questionLine.link.href in shared.json, support.cta.href in faq.json the footer; the e-mail line; “Contact support”

The menu holds Home, About, Services, Stories and Journal; the logo leads Home. The other pages are reached like this:

Page Linked from
Contact “Book a session” in the header, the phone menu and the footer, and the buttons of the copy (“Start your journey”, “Book a consultation”, “Get started”, “Contact us”…)
A post Its card (Home’s “Our journal”, the Journal, “More insights for you.” under another post)
A legal page The footer’s legal links (footer.legalLinks in site.json)
Services, Client Stories Also “Explore programs” and “View all services”, “Read full stories” on Home
Home, About, Services, Stories, Journal Also the footer’s Quick links (the same navigation)

Services and client stories have no page of their own: they are shown in full on Services and Client Stories.

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.

Twelve sections, top to bottom: the hero (the photo, “Available for treatment”, the title, the text, two buttons and the foot line); “About us” with the small photo, “What we believe” and the founder card; “How we can help”, the first four services as rows that open one at a time; the founder quote; “Why choose us”, four points beside four photos, with the call to action band at its end; “Our process”, four numbered steps beside two photos; the plans; the video; “Client stories”, the pinned card turning through four stories, with the four numbers under it; “Our journal”, the three first posts; the questions; the booking section. Their words are in src/content/pages/home.json, apart from the blocks of shared.json, pricing.json, faq.json and book.json.

Home: sections and the files behind them

Six sections: the photo title; “Vision & Mission” with the two cards, a button and two photos; the founder quote; “Our core values”, five values beside five photos; the video; “Meet the team”, every member of team.json with the “+” bio, and the call to action band at its end. The words are in src/content/pages/about.json.

About: sections and the files behind them

Six sections: the photo title; every service as an open card (its number, name, three photos, summary and values), then the four numbers (facts in service.json); the founder quote; the plans; the questions; the booking section.

Services: sections and the files behind them

Three sections: the photo title; every client story as a card as tall as the screen (the headline, the quote, “Key Outcomes:”, the portrait with name and role, and the big photo from tablets up), each stopping at the top while the next slides over it; the call to action band. The words are in src/content/pages/testimonial.json, the stories in testimonials.json.

Client Stories: sections and the files behind them

Three sections: the photo title; every post as a card, three per row on desktops (two on tablets, one on phones), six at first and six more each time the end of the list comes within about 500 px of the screen; the call to action band. The words are in src/content/pages/blog.json, the posts in posts.json.

Journal: sections and the files behind them

Three sections: the article (the category, the title, the excerpt, the cover photo and the body); “More insights for you.”, up to three other posts of the same category, in the order of the file (the section is left out when there are none); the questions. Everything in the first section is the post in posts.json; the heading of the second is src/content/pages/post.json.

Post: sections and the files behind them

Two sections: the booking section as the page’s main section (its title is the page’s <h1>, with the trust block and the form “Tell us about you.”); the questions. The words and the form are in src/content/pages/book.json, the browser title and description in contact.json. Contact has no photo, so the header is solid from the start.

Contact: sections and the files behind them

One section: the title, “Last Updated:” with the date, and the text, in a column at most 900 px wide. Everything but the label is the page in legal.json.

Legal: sections and the files behind them

One section: “Page not found”, a line of text and “Back to homepage”, centred, one screen tall. 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 plans off the home page, delete <PricingSection … /> from src/pages/index.astro; the same file stays in use on Services. To leave the video off About, delete its <VideoSection … /> line.

A few blocks are parts of a bigger section, so they go inside its file or slot: the call to action band on Home and About is the <CtaBandSection … /> between the tags of HomeWhySection and AboutTeamSection (delete that line to remove it there), the numbers of Home are part of HomeStoriesSection.astro (stats), and those of Services part of ServiceMainSection.astro (facts).

Keep the section that follows a photo title (or the Home hero) able to switch the header: the header runs transparent over the photo and turns solid when a section marked headerSwitch (data-header-switch) reaches the middle of the screen. On Home that is “About us”; on About, “Vision & Mission”; on Services, the service cards; on Client Stories, the stories; on the Journal, the list. If you remove or move that section, give the new one headerSwitch on its Section (the header).

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

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

    {
    "meta": {
    "title": "Workshops",
    "description": "Small-group workshops on stress, confidence and communication: dates, topics and how to join the next session near you."
    },
    "pageTitle": {
    "title": "Workshops",
    "lead": "Learn and grow alongside others in small, supportive groups.",
    "image": { "src": "/images/service-hero.jpg", "alt": "A counsellor writing on a clipboard next to a client resting on a sofa" }
    },
    "intro": {
    "label": "Upcoming",
    "title": "Grow together in a small group",
    "text": "Each workshop is a half-day session for up to twelve people, led by one of our coaches."
    }
    }
  3. Create src/pages/workshops.astro:

    ---
    import CtaSection from "../components/sections/CtaSection.astro";
    import PageTitleSection from "../components/sections/PageTitleSection.astro";
    import SectionIntro from "../components/sections/SectionIntro.astro";
    import shared from "../content/pages/shared.json";
    import workshops from "../content/pages/workshops.json";
    import Section from "../design-system/components/layout/Section.astro";
    import Layout from "../layouts/Layout.astro";
    const { clientRatings, ctaBand, questionLine, socialLinks } = shared;
    ---
    <Layout title={workshops.meta.title} description={workshops.meta.description}>
    <PageTitleSection title={workshops.pageTitle.title} lead={workshops.pageTitle.lead} image={workshops.pageTitle.image} />
    <Section headerSwitch>
    <SectionIntro intro={workshops.intro} class="max-w-[620px]" />
    </Section>
    <CtaSection content={ctaBand} ratings={clientRatings} question={questionLine} socials={socialLinks} />
    </Layout>

    PageTitleSection holds the page’s <h1> (every page has one). The section after it carries headerSwitch, so the header turns solid as it comes up. A page without a photo title starts under the solid header by itself: begin it with a plain <Section> and give its title as="h1" (<SectionIntro as="h1" … />).

  4. Link to it: add { "label": "Workshops", "href": "/workshops" } to navigation in src/content/site.json (the menu and the footer’s Quick links). The header’s links are 75 px wide each, so keep the labels short and the menu to about five or six links.

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

Delete its file under src/pages/ (for the Journal, also the folder of the posts), its entry in navigation (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 /service, /testimonial and /contact of the buttons (hero.secondary, service.cta, stories.cta in home.json, the plans’ buttons, bookLink…), 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 legal pages (src/pages/legal/[slug].astro).

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.

  • Fixed. The header stays at the top of every page, 65 px tall on phones and 82 px from tablets up. On Home, About, Services, Client Stories and the Journal it runs transparent over the big photo, with a White logo and links and a frosted pill, and turns solid (the page colour, Green logo and links, a White pill and a Green button) when the section after the photo reaches the middle of the screen, and back when you scroll up. The other pages start under it, with the solid look.
  • Desktop and tablet: the logo on the left; on the right the pill with the links and “Book a session”. A dark pill slides under the link the pointer (or the keyboard) is on. Phone: the logo and a menu button.
  • The phone menu. A press turns the button into a cross and grows the bar over the page, with the links and “Book a session” under them. It closes when a link or the logo is pressed, on Escape and when the window grows to tablet width. src/components/site/header.ts runs it.
  • Load. The logo, the links one after the other and the button rise in on the first page of a visit (and on a reload), not on every page change.
  • The menu is navigation in src/content/site.json. The link of the current page looks like the others; screen readers hear it as the current page (a post or a legal page marks no link).
  • Sitemap: src/pages/sitemap.xml.ts builds sitemap.xml from routes.ts and the collections: the six main pages (Home, About, Services, Client Stories, Journal, Contact), then every post and every legal page: 20 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 (contact.json holds title and description directly); Home uses site.title and site.description. A post takes its title and its excerpt (followed by the start of its first paragraph when the excerpt is under 80 characters), is marked as an article with its date, and shares its cover; a legal page takes its title and its entry in descriptions (legal.json). A title that would be longer than 60 characters with | Metuo appended is shown without the suffix. Every other page shares public/opengraph-image.png.
  • Not indexed: the style guide and the 404 page (noindex).