Pages and sections — Marai Neesu Astro
A page is a small file that picks sections and hands them content. src/pages/product.astro is the whole Products page:
---import ProductsSection from "../components/sections/ProductsSection.astro";import productsPage from "../content/pages/products.json";import Layout from "../layouts/Layout.astro";import { getProducts } from "../lib/content";import { toProductCard } from "../lib/to-ui";
const page = productsPage.products;const products = await getProducts();---
<Layout title={page.meta.title} description={page.meta.description}> <ProductsSection heading="h1" title={page.title} text={page.text} products={products.map((product) => toProductCard(product, { buy: page.buyLabel, details: page.detailsLabel }))} /></Layout>Layout(src/layouts/Layout.astro) gives the page its browser title, description, canonical link and share image, the header and the footer.getProducts()reads the collection (see Editing the content).toProductCardturns each product into what a card shows (src/lib/to-ui.ts).- The section renders them: the title block (
heading="h1"makes its title the page’s<h1>), then every product as a card, three by three on desktops, two on tablets and one on phones.
The pages
Section titled “The pages”13 kinds of page and 33 addresses in the demo. Every address is in src/content/routes.ts; note that Projects, Services
and Products live at /project, /service and /product, in the singular, so a project is
/project/goeboek-real-estate-and-property.
| Page | Address | Page file | Copy (src/content/pages/) |
Items it shows |
|---|---|---|---|---|
| Home | / |
src/pages/index.astro |
home.json |
socials, projects, services, testimonials, products, posts |
| About | /about |
src/pages/about.astro |
about.json |
experiences, tools |
| Projects | /project |
src/pages/project.astro |
projects.json |
projects |
| Project | /project/<slug> |
src/pages/project/[slug].astro |
project.json |
one project, two others |
| Services | /service |
src/pages/service.astro |
services.json |
services |
| Course | /course |
src/pages/course.astro |
courses.json |
— |
| CV | /cv |
src/pages/cv.astro |
cv.json |
projects, experiences, posts |
| Products | /product |
src/pages/product.astro |
products.json |
products |
| Product | /product/<slug> |
src/pages/product/[slug].astro |
products.json |
one product, three others |
| Blog | /blog |
src/pages/blog.astro |
blog.json |
posts |
| Post | /blog/<slug> |
src/pages/blog/[slug].astro |
blog.json |
one post, related posts |
| Contact | /contact |
src/pages/contact.astro |
contact.json |
services (the form’s choices) |
| 404 | any unknown address | src/pages/404.astro |
not-found.json |
— |
Pages are built as files (about.html, project/goeboek-real-estate-and-property.html), which hosts serve at /about
and /project/goeboek-real-estate-and-property (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 | Used on |
|---|---|
HomeHeroSection |
Home |
ProjectsSection |
Home (“My latest work”), Projects (with the breadcrumbs), a project page (“See more projects”) |
ServicesSection |
Home, Services (“Work with Me”) |
TestimonialsSection (with CardSlideshow on phones) |
Home |
ProductsSection |
Home (“Products Spotlight”, with the course banner), Products, a product page (“More Products”) |
PostsSection |
Home (“Latest Articles & Publications”), a post (“See more posts”) |
AboutIntroSection, ExperienceSection, StackSection |
About |
ClientsSection |
Projects |
ProjectHeroSection, ProjectOverviewSection, ProjectHighlightsSection |
Project |
FaqSection |
Services, Course |
CourseSection |
Course |
CvSection |
CV |
ProductDetailsSection |
Product |
BlogListSection, NewsletterSection |
Blog |
PostArticleSection |
Post |
ContactSection |
Contact |
NotFoundSection |
404 |
Most sections are separated by a thin line, <Divider /> (src/design-system/components/layout/Divider.astro), written
in the page file between them. The project, product and post pages end with a floating “Go Back” button
(<GoBack … />, src/design-system/components/actions/GoBack.astro): it goes back to the previous page when that page
is on your site, and to the list (Projects, Products or Blog) otherwise.
Blocks that appear on several pages
Section titled “Blocks that appear on several pages”Some blocks are shown on more than one page. Each page’s file holds its own copy, so a page can say something different; to change a block everywhere, change it in every file that has it:
| Block | Field | Shown on |
|---|---|---|
| “Work with Me”: the title, the text, the price line, “More Details” and the custom-request row | services in home.json; the same fields at the top of services.json |
Home, Services |
| “My latest work”: the title and the text | projects in home.json; title and text in projects.json |
Home, Projects |
| “Products Spotlight”: the title, the text and the card’s labels | products in home.json; products in products.json |
Home, Products |
| “Latest Articles & Publications”: the title and the text | blog in home.json; blog in blog.json |
Home, Blog |
| “Questions? Answers”, its text and “Have more questions?” (the questions themselves differ) | faq in services.json and courses.json |
Services, Course |
| The course’s title and image | course in home.json (the banner); title and cover in courses.json |
Home, Course |
| The greeting and the rolling roles | hero in home.json; profile in cv.json |
Home, CV |
| “Go Back” | goBack in project.json, product in products.json, post in blog.json |
Project, Product, Post |
How the pages link to each other
Section titled “How the pages link to each other”The menu holds Home, Portfolio (the Projects page), About and Service, and the “Contact” button; the phone menu adds Product, Course and Blog. The footer’s two columns link every main page. The other pages are reached like this:
| Page | Linked from |
|---|---|
| CV | “View my Cv” in the footer (footer.cvLink in site.json), “Read more my cv” on About (experience.cvLink in about.json) and the footer’s Index column |
| Course | The course banner on Home (“Learn Now”, course.link in home.json), the phone menu and the footer |
| Products | “All products” on Home and under “More Products”, the phone menu and the footer |
| Blog | “All articles” on Home and under a post, “All Articles” on the CV, the phone menu and the footer |
| A project | Its card (Home, Projects, “See more projects”) and its line on the CV |
| A product | Its card’s “View Details” (Home, Products, “More Products”) |
| A post | Its card (Home, Blog, “See more posts”) and the CV’s Writing |
| Home | The logo, and the avatar on the CV |
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.
Six sections, top to bottom: the hero (the title, your portrait, the greeting over the rolling roles, the intro and
“More About me”, your e-mail and the social tiles); “My latest work” (the first four projects); “Work with Me” (every
service and the custom-request row); “Trusted by Professionals” (every testimonial, as a ticker, or a slideshow on
phones); “Products Spotlight” (the first six products, four on tablets and three on phones) with the course banner under
them; and “Latest Articles & Publications” (the first three posts, two on tablets). Their words are in
src/content/pages/home.json; the e-mail is contact.email in src/content/site.json and the tiles are
socials.json.

Three sections: the intro (the breadcrumb, the long title, three photos and two paragraphs), “My Experiences” (every job
of experiences.json as a card, and two buttons) and the Stack (every tool of tools.json). The words and the photos
are in src/content/pages/about.json.

Projects
Section titled “Projects”Two sections: the breadcrumb, the title and every project of projects.json as a card, two by two; and “My Awesome
Clients” with the client logos moving in a ticker. The words and the logos are in src/content/pages/projects.json.

Project
Section titled “Project”Four sections: the top (the service badge, the title, the summary, Client, Service and Date, and the main image),
“Project Overview” with the first two photos of the gallery, “Key Highlights” with the wide third photo, and “See more
projects” (the first two other projects); then the floating “Go Back”. Everything but the labels is the project in
projects.json; the labels are in src/content/pages/project.json. A project without a gallery shows no photos under
its overview and highlights.

Services
Section titled “Services”Two sections: “Work with Me” (the title, every service as a card and the custom-request row with “Email Me” and “Contact
me”) and the questions, the first one open, with “Have more questions?” and an e-mail link. The words and the questions
are in src/content/pages/services.json, the cards are services.json.

Course
Section titled “Course”Two sections: the course (the title band over its cover, About Course, “What Will You Learn?” with four modules, the
first one open, the Key Learning Outcomes, and the overview card with the price and “Enroll Today”, which stays in view
while the page scrolls on desktops) and the questions. All of it is in src/content/pages/courses.json.

One section, one column: the profile (your avatar linking home, “Available for work”, the greeting and the rolling
roles), About, Contact, Education, Project (the first four projects), Work Experience (the first four jobs),
Certifications and Writing (the first four posts). The words, the education and the certifications are in
src/content/pages/cv.json; the avatar is person.avatar in src/content/site.json.

Products
Section titled “Products”One section: the title and every product of products.json as a card, three by three. The words are products in
src/content/pages/products.json.

Product
Section titled “Product”Two sections: the details (the title and tagline, the specification, “Live Demo” and “Buy - $59”, the Overview, the main
image and the two screenshots) and “More Products” (three other products, four on tablets); then the floating “Go Back”.
The details are the product in products.json; the labels are product in src/content/pages/products.json.

Two sections: the title and the posts as cards (three by three on desktops, two on tablets, one on phones), six at first
and the rest behind “Load More”; and the newsletter, a photo beside the sign-up form (Forms). The words,
the photo and the form are in src/content/pages/blog.json, the posts in posts.json.

Two sections: the article (the breadcrumbs, the title, the cover with the date and the category over it, and the text)
and “See more posts”, up to three other posts of the same category (two on tablets); the section and its line are left
out when there are none. Then the floating “Go Back”. The article is the post in posts.json; the labels are post in
src/content/pages/blog.json.

Contact
Section titled “Contact”One section: the breadcrumb, the title and the lead beside the inquiry form. The words and the form are in
src/content/pages/contact.json (Forms); the choices of “I’m interested in” are the services of
services.json.

Page not found
Section titled “Page not found”One section: “/404”, a title, a line and a button back to Home, centred. 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, and the <Divider /> that goes with it). To take the
testimonials off the home page, delete <TestimonialsSection … /> 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.
A few blocks are parts of a bigger section, so they go inside its file: the course banner under the products on Home
(the course prop of <ProductsSection> in src/pages/index.astro: leave it out and the banner goes), the
custom-request row under the services (ServicesSection.astro), the client logos of Projects (ClientsSection) and the
blocks of the CV (CvSection.astro).
Adding a page
Section titled “Adding a page”-
Add the URL to
src/content/routes.ts:speaking: "/speaking", -
Add its copy to
src/content/pages/speaking.json, with ameta(title, description):{"meta": {"title": "Speaking","description": "Talks and workshops by Marai Neesu on product design, web design and building a one-person studio."},"title": "Talks and workshops","text": "I speak at design events and run hands-on workshops for teams."} -
Create
src/pages/speaking.astro:---import ProjectsSection from "../components/sections/ProjectsSection.astro";import speaking from "../content/pages/speaking.json";import Divider from "../design-system/components/layout/Divider.astro";import Section from "../design-system/components/layout/Section.astro";import SectionTitle from "../design-system/components/layout/SectionTitle.astro";import Layout from "../layouts/Layout.astro";import { getProjects } from "../lib/content";import { toProjectCard } from "../lib/to-ui";const projects = await getProjects();---<Layout title={speaking.meta.title} description={speaking.meta.description}><Section><SectionTitle as="h1" title={speaking.title} text={speaking.text} /></Section><Divider /><ProjectsSection title="Recent work" projects={projects.slice(0, 2).map(toProjectCard)} /></Layout>The page starts under the fixed header by itself:
<main>is padded by the header’s height, so the first section needs no extra space (the header). -
Link to it: add
{ "label": "Speaking", "href": "/speaking" }tonavigationandphoneNavigationinsrc/content/site.json(the menus), or to one of the footer’scolumns. -
Add
routes.speakingto 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 Projects, Products and Blog, also the folder of their item pages), its entries in
navigation, phoneNavigation and the footer’s columns (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 “All works”, “All products”, “All
articles”, “Learn Now”, “View my Cv” and “Contact me” buttons, for example. Search src/content/ for the path.
Pages built from a collection
Section titled “Pages built from a collection”src/pages/project/[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/projects.json, and its page, its card and its sitemap entry appear on the next
build; any other address under /project/ is a 404. The same pattern builds the product pages
(src/pages/product/[slug].astro) and the post pages (src/pages/blog/[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, on every page. The header stays at the top while the visitor scrolls. It is 74 px tall on phones, 84 px on
tablets and 92 px on desktops, and
<main>is padded by that height (pt-[74px] md:pt-[84px] lg:pt-[92px]insrc/layouts/Layout.astro), so every page starts below it. - Desktops: your logo on its pill at the left, the menu in a blurred pill in the middle and the “Contact” button at the right. When the visitor scrolls down, the bar’s background, the logo and the button fade away and only the menu’s pill stays; scrolling up, or a click on the pill, brings them back. While hidden, the logo and the button can’t be reached with the keyboard.
- Tablets: the plain logo, the menu and the button, with no scroll effect.
- Phones: the plain logo and a “Menu” button of three short lines. The menu opens under the bar with every link of
phoneNavigationand the “Contact” button; the label reads “Close” and the lines cross. A tap anywhere in the open menu closes it, and so do Escape and a window that grows to tablet width. - The current page is a black pill in the menu, and screen readers hear it as the current page; a project page marks Portfolio, and in the phone menu a product page marks Product and a post Blog.
- Changing it:
src/components/site/Header.astroholds the markup andsrc/components/site/header.tsthe scroll look and the phone menu.
Search engines
Section titled “Search engines”- Sitemap:
src/pages/sitemap.xml.tsbuildssitemap.xmlfromroutes.tsand the collections: the nine main pages (Home, About, Projects, Services, Course, Blog, CV, Products, Contact), then every project, product and post (with its date): 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(a title of at most 60 characters and a description of 80 to 160: the demo’s are); Home shows its title as it is. The pages built from a collection take theirs from the item: a project its title and summary, a product its title with its tagline and its specification, a post its title and the start of its first paragraph. A title that would be longer than 60 characters with| Marai Neesuappended is shown without the suffix. Posts are shared as articles, with their date. - Not indexed: the style guide and the 404 page (
noindex).