Pages and sections — Balancee Astro
A page is a small file that picks sections and hands them content. src/pages/portfolio.astro is the whole Portfolio page:
---import CtaBand from "../components/sections/CtaBand.astro";import PortfolioList from "../components/sections/PortfolioList.astro";import portfolio from "../content/pages/portfolio.json";import Layout from "../layouts/Layout.astro";import { getPortfolio } from "../lib/content";
const items = await getPortfolio();---
<Layout title={portfolio.meta.title} description={portfolio.meta.description}> <PortfolioList content={portfolio} items={items} /> <CtaBand /></Layout>Layout(src/layouts/Layout.astro) gives the page its browser title, description, canonical link, share image and icons, the header and the footer.PortfolioListis the title and every case study as a photo card, read fromportfolio.jsonand from the collection throughsrc/lib/content.ts(getPortfolio()), turned into what a card shows bysrc/lib/to-ui.ts.CtaBandis the closing band, read fromshared.jsonby the section itself.
The pages
Section titled “The pages”11 kinds of page and 33 addresses in the demo (plus the 404 page and the style guide, which are not 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, shared.json |
the first six services, six case studies chosen by slug, the three first posts |
| About | /about |
src/pages/about.astro |
about.json, shared.json |
the timeline, the awards and the team of about.json |
| Services | /service |
src/pages/service.astro |
service.json, shared.json |
every service |
| Service (8) | /service/<slug> |
src/pages/service/[slug].astro |
service.json, shared.json |
one service, the first three others |
| Portfolio | /portfolio |
src/pages/portfolio.astro |
portfolio.json, shared.json |
every case study |
| Case study (8) | /portfolio/<slug> |
src/pages/portfolio/[slug].astro |
portfolio.json, shared.json |
one case study, the first two others |
| Blog | /blog |
src/pages/blog.astro |
blog.json, shared.json |
every post |
| Post (9) | /blog/<slug> |
src/pages/blog/[slug].astro |
blog.json, shared.json |
one post, up to two others of its category |
| Contact | /contact |
src/pages/contact.astro |
contact.json, shared.json, site.json |
— |
| Legal (2) | /legal/<slug> |
src/pages/legal/[slug].astro |
legal.json, shared.json |
one legal page |
| 404 | any unknown address | src/pages/404.astro |
not-found.json, shared.json |
— |
All 33 addresses of the demo: /, /about, /service, /service/business-strategy,
/service/operations-optimization, /service/organizational-development, /service/innovation-growth,
/service/market-entry-expansion, /service/financial-performance, /service/change-management,
/service/data-insights, /portfolio, eight case studies under /portfolio/ (retail-revive, tech-innovate,
finance-rebound, health-streamline, global-expand, eco-strive, lead-excel, merge-mastery), /blog, nine posts
under /blog/, /contact, /legal/terms-of-service and /legal/privacy-policy. The style guide is /style-guide.
Pages are built as files (about.html, blog/the-future-of-ai-opportunities-and-challenges.html), which hosts serve at
/about and /blog/the-future-of-ai-opportunities-and-challenges (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).
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 |
|---|---|---|
HomeHero, HomeClients, HomeServices, HomeAbout, HomeProcess, HomeCaseStudies, HomeTestimonials, HomeBlog |
one file each | Home |
AboutHero, AboutWho, AboutJourney, AboutTeam |
one file each | About |
ServicesList, ServicesProcess, ServicesContact |
one file each | Services |
ServiceHero, ServiceWhatWeDo, ServiceOffered, ServiceProcess, ServiceOther |
one file each | A service |
PortfolioList |
PortfolioList.astro |
Portfolio |
CaseStudy, OtherCaseStudies |
one file each | A case study |
BlogList |
BlogList.astro |
Blog |
PostArticle, PostOther |
one file each | A post |
ContactMain (with ContactForm) |
ContactMain.astro |
Contact |
LegalPageBody |
LegalPageBody.astro |
A legal page |
NotFoundBody |
NotFoundBody.astro |
404 |
CtaBand |
CtaBand.astro |
Home, About, Portfolio, a case study, Blog, a post, a service, a legal page, 404 |
ContactForm (the contact form) is also used by ServicesContact. The header and the footer are in
src/components/site/ and come with Layout.
Blocks that appear on several pages
Section titled “Blocks that appear on several pages”Several blocks come from one file, so changing them there changes every page that shows them:
| Block | Field | Shown on |
|---|---|---|
| The call-to-action band “Ready to move your business forward?” | ctaBand in shared.json |
Home, About, Portfolio, Blog, a service, a case study, a post, a legal page, 404 |
| “How we work”: the heading and the four steps | process in shared.json |
Home, Services, a service page (with its own four steps from the service) |
| The “Want to know what’s possible?” pill | process.action in shared.json; detail.action in service.json for a service page |
Home, a service page |
| The consultation prompt (“Let’s talk about your goals…”) | consultation in shared.json |
About (“Who We Are”), Home’s testimonials |
| The contact form’s fields, button and messages | contactForm in shared.json |
Contact, Services |
| The line under the form with the links to the legal pages | formLegal in shared.json |
Contact, Services |
| The menu and “Contact us” | navigation, contactLink in site.json |
the header, the phone menu |
| The footer | footer in site.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 figures | about.facts in home.json; hero.mainFact and hero.facts in about.json; each case study’s results.stats |
Home, About, case studies |
| The three videos | hero.video, about.video, testimonials.items[0].video in home.json |
Home |
| The social links | socials in site.json |
the footer and Contact |
| Your e-mail | contact.email in site.json |
the footer and Contact |
| The booking link | consultation.link.href and ctaBand.secondary.href in shared.json |
the consultation prompt and the band |
How the pages link to each other
Section titled “How the pages link to each other”The menu holds Home, About, Services, Portfolio and Blog; the logo leads Home. The other pages are reached like this:
| Page | Linked from |
|---|---|
| Contact | “Contact us” in the header and the phone menu, the footer’s quick links, “Let’s talk” and the buttons of the copy (“Get in Touch”, “Get started now”, “Let’s work together”…) |
| A service | Its card (Home, Services, “Other services”), the footer’s row of services |
| A case study | Its card (Home, Portfolio, “Other case studies”), Home’s accordion rows (“See detail”), the footer’s “Case Study” column |
| A post | Its card (Home’s “Insights that drive better business”, Blog, “Other blogs”) |
| A legal page | The footer’s legal links (footer.legalLinks in site.json) and the line under the contact form (formLegal) |
| Portfolio, Blog, Services, About | Also “View all case studies”, “See all blog”, “View all services”, “More about us”, “Our services” and the footer’s quick links |
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.
Nine sections, top to bottom: the hero (the title with the client rating, the text, two buttons, and the video with the
wordmark and a caption over it); “Trusted by clients across the world” (the ticker of six logos); “Services built for
growth” (the first six services as cards); “About Balancee” (three figures, the text, a small clip and a tall photo);
“How we work” (a photo with a pill and four steps); “Case Studies” (two photo cards and “Recent case studies” as an
accordion); “What our clients say” (the dark card, the video card and two quote cards, with the consultation prompt on a
photo); “Insights that drive better business” (the three first posts); the call-to-action band. Their words are in
src/content/pages/home.json, apart from shared.json (the steps, the prompt and the band).

Five sections: the top block (breadcrumbs, title, text, the “Our services” button and the social links beside a grid of
two photos and figure cards); “Who We Are” (three cards and four photos, the last with the consultation prompt); “Our
Journey” (the timeline of six years and the awards, on black); “Our Team” (the six members as cards, the bio and the
LinkedIn button sliding up on hover on desktops); the call-to-action band. The words are in src/content/pages/about.json.

Services
Section titled “Services”Three sections: the title with every service as a card; “How we work” (the four steps in a row, on a grey band); “Get in
Touch” (a text and the contact form). The words are in src/content/pages/service.json and shared.json, the cards in
services.json. The page has no call-to-action band.

Service
Section titled “Service”Six sections: the top (the name, the intro, a button, “What we offer” as chips, and the photo); “What we do” (a photo and
a text); “Services Offered” (six numbered cards); “How we work” (a photo with a pill, and the service’s four steps);
“Other services” (the first three others); the call-to-action band. Everything but the labels is the service in
services.json; the labels are detail in src/content/pages/service.json.

Portfolio
Section titled “Portfolio”Two sections: the title with every case study as a photo card, two across, four at first and four more each time the
spinner at the bottom comes within about 500 px of the screen; the call-to-action band. The words are in
src/content/pages/portfolio.json, the case studies in portfolio.json (collection).

Case study
Section titled “Case study”Three sections: the page (the name chip, the headline and summary, the cover photo, four fact boxes, then Overview,
Client Challenges, Solutions and Results, with the three figures); “Other case studies” (the first two others); the
call-to-action band. Everything but the labels is the case study in portfolio.json (collection); the labels are detail
in src/content/pages/portfolio.json.

Two sections: the title with every post as a card, three across on desktops (two on tablets, one on phones), four at first
and four more as the end of the list comes near; the call-to-action band. The words are in src/content/pages/blog.json,
the posts in posts.json.

Three sections: the article (the title and excerpt, the author, the category and the date, the cover photo and the body);
“Other blogs” (up to two other posts of the same category, left out when there are none); the call-to-action band.
Everything in the first section is the post in posts.json; the heading of the second is post in
src/content/pages/blog.json.

Contact
Section titled “Contact”One section: the title and the details (e-mail, phone, location, hours, social links) on the left and the contact form on
the right. The words are in src/content/pages/contact.json and site.json, the form in shared.json. The page has no
call-to-action band.

Two sections: the title, “Last updated:” with the date, and the text, in a centred column; the call-to-action band.
Everything but the label is the page in legal.json (collection).

Page not found
Section titled “Page not found”Two sections: “404 Error”, “Something went wrong.”, a line of text and “Go to homepage”, centred; the call-to-action band.
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 testimonials off the home page, delete
<HomeTestimonials … /> from src/pages/index.astro; to leave the band off a page, delete its <CtaBand /> line. To
leave a video out, remove the section that plays it: the hero’s is HomeHero, the small clip is part of HomeAbout and
the testimonial video part of HomeTestimonials.
The header is white and the same at every scroll position, so no section needs to mark itself for it, and every page starts
below the header’s spacer in <main>.
Adding a page
Section titled “Adding a page”-
Add the URL to
src/content/routes.ts:careers: "/careers", -
Add its copy to
src/content/pages/careers.json, with ameta(title, description):{"meta": {"title": "Careers","description": "Join Balancee: open roles for strategists, analysts and consultants, and what it is like to work with our team."},"hero": {"breadcrumb": "Careers","title": "Build your career with us","text": "We are always looking for people who like hard problems."}} -
Create
src/pages/careers.astro:---import CtaBand from "../components/sections/CtaBand.astro";import careers from "../content/pages/careers.json";import { routes } from "../content/routes";import PageTitle from "../design-system/components/layout/PageTitle.astro";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><PageTitle crumbs={[{ label: "Home", href: routes.home }, { label: careers.hero.breadcrumb }]} title={careers.hero.title} lead={careers.hero.text} /></Section><CtaBand /></Layout>PageTitleholds the page’s<h1>(every page has one). Look atsrc/components/sections/ServicesList.astrofor the same title with a list under it. -
Link to it: add
{ "label": "Careers", "href": "/careers" }tonavigationinsrc/content/site.json(the menu), and tofooter.quickLinksif it belongs in the footer. The header’s links sit in one row with the logo and the button, so keep the labels short and the menu to about six links. -
Add
routes.careersto thepathslist 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 the Blog, Services or Portfolio, also the folder of the items), its entry in
navigation and footer.quickLinks (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 /contact, /service and /portfolio of the buttons (hero.primary,
hero.secondary, ctaBand.primary, detail.cta…), for example. Search src/content/ for the path.
Pages built from a collection
Section titled “Pages built from a collection”src/pages/blog/[slug].astro builds one page per post:
export async function getStaticPaths() { const posts = await getPosts(); return Promise.all(posts.map(async (post) => ({ params: { slug: post.slug }, props: { post, related: await getRelatedPosts(post, blog.post.otherCount) } })));}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 services (src/pages/service/[slug].astro), the
case studies (src/pages/portfolio/[slug].astro) and the legal pages (src/pages/legal/[slug].astro).
The 404 page
Section titled “The 404 page”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.
The header
Section titled “The header”- Fixed and white. The header stays at the top of every page, 60 px tall on phones, 71 px on tablets and 75 px on desktops, and does not change while you scroll.
- Desktop: the logo on the left, the links in the middle and the “Contact us” button on the right; the page you are on is a filled Ink pill, and the other links get an underline on hover. Tablet: the logo and the links (the button appears from desktop width). 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
“Contact us” under them. It closes when a link or the logo is pressed, and on Escape.
src/components/site/header.tsruns it. - The menu is
navigationinsrc/content/site.json. The link of the current page is marked for screen readers as well; a service, a case study or a post marks its section’s link (Services, Portfolio, Blog).
Search engines
Section titled “Search engines”- Sitemap:
src/pages/sitemap.xml.tsbuildssitemap.xmlfromroutes.tsand the collections: the six main pages (Home, About, Services, Portfolio, Blog, Contact), then every service, case study, post and legal page: 33 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; Home usessite.titleand themeta.descriptionofhome.json. A service takes its name and the first sentences of itsintro; a case study its name and itssummaryand shares its own cover; 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, author and category, and shares its cover; a legal page takes its title and its date. A title that would be longer than 60 characters with| Balanceeappended is shown without the suffix. Every other page sharespublic/opengraph-image.png. - Not indexed: the style guide and the 404 page (
noindex).