Skip to content
Sign inJoin waitlist

Pages and sections — Semono Astro

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

---
import BlogListSection from "../components/sections/BlogListSection.astro";
import blog from "../content/pages/blog.json";
import Layout from "../layouts/Layout.astro";
import { getPosts } from "../lib/content";
import { toPostCard } from "../lib/to-ui";
const posts = await getPosts();
---
<Layout title={blog.meta.title} description={blog.meta.description}>
<BlogListSection label={blog.label} title={blog.title} text={blog.text} loading={blog.loading} posts={posts.map(toPostCard)} />
</Layout>
  • Layout (src/layouts/Layout.astro) gives the page its browser title, description, canonical link and share image, the header, the footer and the page change.
  • getPosts() reads the collection (see Editing the content). toPostCard turns each post into what a card shows (src/lib/to-ui.ts).
  • The section renders them: the title block, then every post as a card in columns, six at a time on desktop and four on tablets and phones, more as the visitor scrolls.

13 kinds of page and 33 addresses in the demo. Every address is in src/content/routes.ts; note that Services and Careers live at /service and /career, in the singular, so a service is /service/business-strategy.

Page Address Page file Copy (src/content/pages/) Items it shows
Home / src/pages/index.astro home.json clients, services, testimonials, posts
About /about src/pages/about.astro about.json team, testimonials
Team /team src/pages/team.astro team.json team
Careers /career src/pages/career.astro careers.json careers
Career /career/<slug> src/pages/career/[slug].astro career.json one position
Services /service src/pages/service.astro services.json services, clients, testimonials
Service /service/<slug> src/pages/service/[slug].astro service.json one service, four others
Testimonial /testimonial src/pages/testimonial.astro testimonials.json testimonials, posts
Blog /blog src/pages/blog.astro blog.json posts
Post /blog/<slug> src/pages/blog/[slug].astro post.json one post, related posts
Contact /contact src/pages/contact.astro contact.json —
Legal page /legal/<slug> src/pages/legal/[slug].astro legal.json one legal page
404 any unknown address src/pages/404.astro not-found.json —

Pages are built as files (about.html, service/business-strategy.html), which hosts serve at /about and /service/business-strategy (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 File Used on
HomeHeroSection, ClientsSection, HomeAboutSection, HomeServicesSection, WhyChooseSection, CtaBandSection, HomeTestimonialsSection, HomeBlogSection one file each Home
ProcessSection (with ProcessTabs and ProcessDetails) ProcessSection.astro, ProcessTabs.astro, ProcessDetails.astro Home
ActionSection (with ActionCard) ActionSection.astro, ActionCard.astro Home, Testimonial
AboutIntroSection, AboutMissionSection, AboutTeamSection one file each About
TeamGridSection TeamGridSection.astro Team
CareersSection CareersSection.astro Careers
CareerSection CareerSection.astro Career
ServicesListSection, ServicesProcessSection, ServicesTestimonialsSection one file each Services
ServiceMainSection, ServiceActionSection, ServiceOtherSection one file each Service
TestimonialsMainSection, LatestPostsSection one file each Testimonial
BlogListSection (with BlogList) BlogListSection.astro, BlogList.astro Blog
PostArticleSection, PostRelatedSection one file each Post
ContactSection ContactSection.astro Contact
LegalSection LegalSection.astro Legal
NotFoundSection NotFoundSection.astro 404

Some parts are shared between sections: ClientsRow.astro (the logo ticker) is in ClientsSection and also ends ServicesProcessSection; ProcessSteps.astro is in ProcessSection and also on Services; ActionCard.astro is the black card of ActionSection and of “How We Work” on Services, and the white card of the consultation form; TestimonialMasonry.astro (the grid of client cards) serves HomeTestimonialsSection and ServicesTestimonialsSection. The shapes they share are in src/components/sections/types.ts.

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
The four figures facts in home.json and about.json Home (“About Semono”), About (the intro)
The four icon cards about.cards in home.json, mission.cards in about.json Home (“About Semono”), About (“Our Mission & Values”)
The closing call to action: the black card, its buttons and its photo action in home.json and testimonials.json; process.action in services.json (the title, text, first button and photo) Home, Testimonial, and the black card of “How We Work” on Services
The black card of the consultation form (its title and text) servicePage.action in service.json every service page
“Latest Insights”: label, title and text blog in home.json and testimonials.json Home, Testimonial
The four steps of the process process.steps in home.json and services.json Home, Services (“How We Work”)
The title over the client logos clients.title in home.json, process.clientsTitle in services.json Home, Services
The heading over the client cards testimonials in home.json and services.json Home, Services
“What’s Included:” and “Learn more” on the service rows services.included and services.more in home.json; included and more in services.json; servicePage.other in service.json Home, Services, “Other services”

The menu holds Home, About, Services and Blog, and the “Contact us” button. The other pages are reached like this:

Page Linked from
Team The black card at the end of About’s team row, “View full team” (team.more.link in about.json)
Careers The footer’s Quick Links (footer.quickLinks in site.json) and the black card of the Team page, “We are hiring” (join.link in team.json)
A career The “More details” button of each position on Careers
Testimonial “View all reviews” in “Why Choose Semono” on Home (why.story.link in home.json)
A service The “Learn more” of every row (Home, Services, “Other services”) and the footer’s Services column
A post Its card (Home, Blog, Testimonial, “Related articles”)
Legal pages The footer’s legal links (footer.legalLinks in site.json)

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.

Ten sections, top to bottom: the hero; “Trusted by leading brands” (the logo ticker); “About Semono” with four figures; “Our Services” with the closing line, a client quote and the video; “Why Choose Semono”; a photo band with a call to action; the process (four steps and three tabs); “Client Testimonials”; a closing call to action; “Latest Insights”. Their words are in src/content/pages/home.json, and so are the figures, the six reasons, the tabs and the booking link. The ticker shows every client of clients.json; the rows of “Our Services” are the first four services (services.limit); the quote beside the closing line is the fourth testimonial and the client story in “Why Choose” the first (the grid of cards shows up to eight, Editing the content); “Latest Insights” shows the first three posts. The header lies over the hero and turns light when “About Semono” reaches the middle of the screen (the header).

Home: sections and the files behind them

Three sections: the intro (the title, a wide photo, “Our Story” and the four figures), “Our Mission & Values” (four cards, the video, a closing line with a client quote) and “Our Team”. The words, the figures and the cards are in src/content/pages/about.json. The quote is the third testimonial; the team row shows the first three members of team.json (team.limit) and a black card linking to the Team page.

About: sections and the files behind them

One section: the title, every member of team.json as a card (portrait, LinkedIn button, name and role), a wide photo and a black card inviting to Careers. The words, the photo and the card are in src/content/pages/team.json.

Team: sections and the files behind them

One section: the title, three photos beside four cards (perks), and “Open Positions”: every position of careers.json as a row with a “More details” button (no paging). The words, the photos and the cards are in src/content/pages/careers.json.

Careers: sections and the files behind them

One section: the position’s title, its location and type, the overview and three bulleted lists, and a white card with the application form (Forms). All the text is the position in careers.json; the labels and the form are in src/content/pages/career.json. One page exists per position, and its browser title is the title with its location.

Career: sections and the files behind them

Three sections: the title and every service as a numbered row, four at a time as the visitor scrolls (all six are in the page’s HTML); “How We Work” (four steps, a black card with a button and a photo, and the client logos); and the grid of client cards. The words, the steps, the card, the logos’ title and the cards’ heading are in src/content/pages/services.json (blocks on several pages). The rows are services.json, the logos clients.json and the cards testimonials.json.

Services: sections and the files behind them

Three sections: the main part (the service’s name and summary, a wide photo, the overview beside “What’s Included”, a gallery of three photos beside four “What We Deliver” cards, and four numbers), a white card with the consultation form beside a photo (Forms), and “Other services” (four rows and a button to all of them). Everything in the main part is the service in services.json; the labels, the card’s text and photo, the form and “Other services” are in src/content/pages/service.json. The “Service Required” field of the form starts with the page’s own service.

Service: sections and the files behind them

Three sections: every client story as a wide row (four at a time as the visitor scrolls), the closing call to action and “Latest Insights” with the first three posts. The stories are testimonials.json; the title, the closing card and the heading of “Latest Insights” are in src/content/pages/testimonials.json.

Testimonial: sections and the files behind them

One section: the title and every post as a card in columns (three on desktop, two on tablets, one on phones): six at first on desktop, four on tablets and phones, and more each time the spinner under the list comes within about 500 px of the screen. Every post is in the page’s HTML from the start, so search engines find them all. The words are in src/content/pages/blog.json, the posts in posts.json.

Blog: sections and the files behind them

Two sections: the article (the title, the excerpt, the category and date, the wide cover and the text) and “Related articles”, up to three other posts of the same category; the section is left out when there are none. The article is the post in posts.json; the heading is in src/content/pages/post.json.

Post: sections and the files behind them

One section: the title; the contact details beside the inquiry form; and the FAQ of eight questions. The title, the labels, the business hours, the FAQ and the form are in src/content/pages/contact.json (Forms); the e-mail, the phone number and the address are contact in src/content/site.json.

Contact: sections and the files behind them

One section: the title, “Last updated on” with its date, and the text. They are the legal page in src/content/collections/legal.json; “Last updated on” is in src/content/pages/legal.json. The footer links the two demo pages.

Legal page: sections and the files behind them

One section: a full-window photo under a dark layer with the header floating over it, a title, a text 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 process off the home page, delete <ProcessSection … /> 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 FAQ of Contact (everything under the <hr /> in ContactSection.astro), the closing line and quote of “Our Services” (<ActionQuote … /> in HomeServicesSection.astro) and the two videos (Editing the content).

On Home, the header turns light at the “About Semono” block, the section marked headerSwitch (<Section id="about" headerSwitch> in HomeAboutSection.astro). If you remove HomeAboutSection, put headerSwitch on the section that should take over, or the header stays transparent, with white text, all the way down Home.

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

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

    {
    "meta": {
    "title": "Industries",
    "description": "The industries Semono works with: technology, finance, corporate services and fast-growing start-ups."
    },
    "label": "Industries",
    "title": "Experience across every kind of business",
    "text": "From start-ups to established groups, we adapt our consulting approach to the way your industry works."
    }
  3. Create src/pages/industries.astro:

    ---
    import ActionSection from "../components/sections/ActionSection.astro";
    import home from "../content/pages/home.json";
    import industries from "../content/pages/industries.json";
    import siteContent from "../content/site.json";
    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={industries.meta.title} description={industries.meta.description}>
    <Section>
    <PageTitle label={industries.label} title={industries.title} text={industries.text} balance />
    </Section>
    <ActionSection {...home.action} name={siteContent.site.name} />
    </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). ActionSection here is Home’s closing call to action, read from home.json; give the page its own action in industries.json if it should say something else.

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

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

Delete its file under src/pages/ (for Careers, Services, Blog and the legal pages, also the folder of their item pages), its entry in navigation and the footer’s 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 /contact, /service, /about, /team, /career and /testimonial of the buttons and cards, and the footer’s Quick Links, for example. Search src/content/ for the path.

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

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

Add a service to src/content/collections/services.json, and its page, its row and its sitemap entry appear on the next build; any other address under /service/ is a 404. The same pattern builds the post pages (src/pages/blog/[slug].astro), the career pages (src/pages/career/[slug].astro) and the legal pages (src/pages/legal/[slug].astro).

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.

  • Fixed, and it never hides. The header stays at the top of every page while the visitor scrolls. It is 58 px tall on phones and 82 px from tablets up. It rises into place as the first page of a visit loads, and stays still on the pages after it (Making it look like your brand).
  • Over the photo on Home and the 404 page. Both open with a full-window photo whose section carries data-header-cover (HomeHeroSection.astro, NotFoundSection.astro). There the header is transparent, with a white logo and links, over the photo. On Home it turns light (the page background with black text) once the “About Semono” block reaches the middle of the screen, fading in 0.37 s, and goes transparent again when the visitor scrolls back above that point. The 404 page has no such block, so its header stays transparent.
  • Every other page starts below a spacer: the header is light from the first paint, and <main> is padded by its height (pt-[58px] md:pt-[82px] in src/layouts/Layout.astro).
  • Changing it. To put the header over a photo on another page, start that page with a dark, full-window section marked data-header-cover: it must be a direct child of <main> (the page’s first section), which then loses its padding. Mark a later section with headerSwitch (a prop of Section) if the header should turn light there. To give Home the light header of the other pages, remove the mark from HomeHeroSection.astro. The looks are chosen in CSS (body:has([data-header-cover]) in src/components/site/Header.astro), so nothing jumps after the page loads; src/components/site/header.ts turns the header light and runs the phone menu.
  • The menu is navigation in src/content/site.json, and the button contactLink. The link of the current page looks like the others; screen readers hear it as the current page (a service, post, career or legal page marks no link). On phones the bar holds the logo and a menu button of three lines; the menu opens under the bar with the links and the “Contact us” button, and closes when a link is followed, when the visitor presses Escape and when the window grows to tablet width.
  • Sitemap: src/pages/sitemap.xml.ts builds sitemap.xml from routes.ts and the collections: the eight main pages (Home, About, Team, Careers, Services, Blog, Contact, Testimonial), then every position, service, post (with its date) and legal page (with its update date): 33 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 (a title of at most 60 characters and a description of 80 to 160: the demo’s are); Home uses site.title and site.description. The pages built from a collection take theirs from the item: a service its name and summary, a career its title with its location and its summary, a post its title and excerpt, a legal page its title and first paragraph. A title that would be longer than 60 characters with | Semono appended is shown without the suffix. Services and posts share their own photo; posts are shared as articles, with their date.
  • Not indexed: the style guide and the 404 page (noindex).