To build a school website with Astro, model news, events and staff as content collections, publish term dates as both a page and a subscribable .ics calendar feed, keep policies and newsletters as versioned documents, design to WCAG 2.1 AA, and deploy the static build to a host that rebuilds when staff publish. A school website built with Astro is fast on parents’ phones, has no login page or plugins to attack, and is cheap enough to run on a school’s budget.
This guide covers the pages schools need, the Astro 7 code for the trickier parts, and how to let office staff update the site.
Key Takeaways
- Parents visit for term dates, news, letters, lunch menus and contact details. Make those one tap from the home page.
- Generate an
.icscalendar feed from your events collection so families can subscribe in their phone’s calendar.- Keep statutory documents and policies at stable URLs, with a “last reviewed” date.
- Accessibility is a legal requirement for many schools. Build to WCAG 2.1 AA from the start.
- Add a git-based or headless CMS so office staff publish news without touching code.
What a school website needs
School websites serve several audiences at once: current parents, prospective families, students, staff, inspectors and the local community. Current parents are the most frequent visitors by far, so their tasks should be the fastest.
| Section | Contents | Main audience |
|---|---|---|
| Home | Alerts (closures), latest news, term dates, quick links | Parents |
| About | Ethos, leadership, governors, history | Prospective families |
| Admissions | How to apply, deadlines, open days, tours | Prospective families |
| News and letters | Updates, newsletters, letters home | Parents |
| Calendar | Term dates, events, INSET days | Parents, staff |
| Curriculum | Subjects, year groups, clubs | Parents, inspectors |
| Policies | Safeguarding, behavior, SEND, privacy, complaints | Parents, inspectors |
| Contact | Address, phone, office hours, absence reporting | Everyone |
Many countries require schools to publish specific information online. Check your local requirements and give each item a permanent URL.
Create the project
# Terminal
npm create astro@latest school-site
cd school-site
npx astro add sitemap mdx
npm run dev
On themes: the Astro education themes category is small, with 37 themes, and most are built for online courses and universities rather than primary or secondary schools. Academic CMS is the closest fit for an institution, with courses, blog and contact pages. Free options are similar: general templates such as AstroWind or Astro’s official blog starter give you news and layout, and you’ll add the calendar and policy sections yourself using the code below.
Content collections for news, events and staff
// src/content.config.ts
import { defineCollection } from 'astro:content';
import { glob, file } from 'astro/loaders';
import { z } from 'astro/zod';
const news = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/news' }),
schema: ({ image }) =>
z.object({
title: z.string(),
pubDate: z.coerce.date(),
summary: z.string().max(200),
yearGroups: z.array(z.string()).default(['All']),
image: image().optional(),
imageAlt: z.string().optional(),
}),
});
const events = defineCollection({
loader: file('src/data/events.json'),
schema: z.object({
title: z.string(),
start: z.coerce.date(),
end: z.coerce.date().optional(),
allDay: z.boolean().default(true),
category: z.enum(['term', 'holiday', 'inset', 'event', 'exam']),
location: z.string().optional(),
}),
});
const policies = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/policies' }),
schema: z.object({
title: z.string(),
document: z.string(),
reviewed: z.coerce.date(),
nextReview: z.coerce.date(),
}),
});
export const collections = { news, events, policies };
Events use the file() loader with a single JSON array, because term dates are usually typed in as a batch at the start of the year. Each object needs an id field:
[
{ "id": "autumn-start", "title": "Autumn term starts", "start": "2026-09-03", "category": "term" },
{ "id": "inset-oct", "title": "INSET day (school closed to pupils)", "start": "2026-10-23", "category": "inset" },
{ "id": "half-term", "title": "Half term", "start": "2026-10-26", "end": "2026-10-30", "category": "holiday" }
]
The nextReview date on policies lets you build a small report page that lists anything overdue for review. The content layer loaders guide explains glob() and file() in detail.
A calendar page and a subscribable feed
Parents want term dates on their own calendar, not on your website. Give them both.
The page:
---
// src/pages/calendar/index.astro
import { getCollection } from 'astro:content';
import BaseLayout from '../../layouts/BaseLayout.astro';
const events = (await getCollection('events')).sort(
(a, b) => a.data.start.getTime() - b.data.start.getTime(),
);
const fmt = new Intl.DateTimeFormat('en-GB', { weekday: 'short', day: 'numeric', month: 'long', timeZone: 'UTC' });
---
<BaseLayout title="Term dates and calendar">
<h1>Term dates and calendar</h1>
<p><a href="/calendar.ics">Subscribe to the school calendar</a> in Google Calendar, Apple Calendar or Outlook.</p>
<table>
<thead><tr><th scope="col">Date</th><th scope="col">Event</th></tr></thead>
<tbody>
{events.map((e) => (
<tr class={e.data.category}>
<td>{fmt.format(e.data.start)}{e.data.end && ` to ${fmt.format(e.data.end)}`}</td>
<td>{e.data.title}</td>
</tr>
))}
</tbody>
</table>
</BaseLayout>
The feed is a static endpoint. Astro runs it at build time and writes dist/calendar.ics:
// src/pages/calendar.ics.ts
import type { APIRoute } from 'astro';
import { getCollection } from 'astro:content';
const day = (d: Date) => d.toISOString().slice(0, 10).replaceAll('-', '');
const nextDay = (d: Date) => day(new Date(d.getTime() + 86_400_000));
export const GET: APIRoute = async ({ site }) => {
const events = await getCollection('events');
const host = site?.hostname ?? 'school.example';
const lines = [
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//School//Calendar//EN',
'X-WR-CALNAME:School calendar',
...events.flatMap((e) => [
'BEGIN:VEVENT',
`UID:${e.id}@${host}`,
`DTSTAMP:${day(new Date())}T000000Z`,
`DTSTART;VALUE=DATE:${day(e.data.start)}`,
`DTEND;VALUE=DATE:${nextDay(e.data.end ?? e.data.start)}`,
`SUMMARY:${e.data.title.replace(/[,;]/g, '\\$&')}`,
'END:VEVENT',
]),
'END:VCALENDAR',
];
return new Response(lines.join('\r\n'), {
headers: { 'Content-Type': 'text/calendar; charset=utf-8' },
});
};
All-day events in iCalendar use an exclusive end date, which is why DTEND is the day after the last day. Calendar apps refresh subscribed feeds on their own schedule, so changes reach parents within hours, not instantly. For more on endpoints, see the API endpoints guide and the official endpoints docs.
Closure alerts
Snow days and emergencies need a banner on every page, fast. Keep it in a tiny data file that office staff can edit:
// src/data/alert.ts
export const alert = {
active: false,
message: 'School is closed today due to snow. Remote learning details have been emailed.',
updated: '2026-12-02T06:45:00Z',
};
---
// src/components/AlertBanner.astro
import { alert } from '../data/alert';
---
{alert.active && (
<div role="alert" class="alert">
<p>{alert.message}</p>
</div>
)}
Because the site is static, the banner appears after the next build, usually a minute or two on Cloudflare Pages or Netlify. That’s fine for most alerts, but keep your text message and email system as the primary emergency channel.
Policies and documents
Policies are often PDFs, and inspectors look for them. A few rules keep them manageable:
- Store files in
public/documents/with stable names likesafeguarding-policy.pdf. Replace the file when updated so the URL never changes. - Give each a policy entry with
reviewedandnextReviewdates, and show “Last reviewed” on the policy page. - Where you can, publish the policy as an HTML page too. HTML is easier to read on a phone and easier for screen readers than a scanned PDF.
Accessibility is a requirement
Public schools in many countries are legally required to meet accessibility standards online. In the US, for example, a 2024 Department of Justice rule under Title II of the ADA sets WCAG 2.1 AA as the standard for state and local government websites, including public schools. Build to that level from the start:
- Semantic headings and landmarks (
header,nav,main,footer). - Tables with
<th scope="col">headers, as in the calendar above. - Every image with meaningful
alttext; Astro’s<Image />errors at build time without it. - Color contrast of at least 4.5:1 for body text.
- Visible keyboard focus on every link and button.
- PDFs that are tagged and text-based, not scans.
Run an automated checker and a keyboard-only walkthrough before launch, then repeat each term.
Let office staff update the site
The person updating a school site is usually in the office, not IT. Give them a form-based editor:
- Git-based CMS such as Decap CMS or Keystatic edits the same Markdown files through a web interface. Each save commits to the repo and triggers a rebuild. No database, no extra hosting.
- Headless CMS such as Sanity or Storyblok offers a richer editor and roles, and calls a build webhook on publish.
The headless CMS guide compares the options for Astro. Whichever you choose, configure fields that match your collection schemas so staff can’t publish a news post without a date or summary.
Deploy and schedule rebuilds
Run npm run build and deploy dist/ to Cloudflare Pages, Netlify or Vercel. The static deploy docs cover each. Two extras for schools:
- A daily scheduled rebuild so “upcoming events” stays accurate without anyone publishing.
- A custom domain on the school’s existing domain, with HTTPS (all three hosts provide it free).
Since nothing runs on a server, there are no security patches for the website itself, only occasional npm update runs to keep Astro current.
FAQ
Is Astro a good choice for a school website?
Yes. Astro builds static pages that are fast on phones, has no admin login or plugins to secure, and can be hosted cheaply. News, events, staff and policies map well to content collections, and a git-based or headless CMS lets office staff publish without code.
How do I add a calendar to an Astro school website?
Store events in a content collection, render them as a table on a calendar page, and add a static endpoint such as src/pages/calendar.ics.ts that outputs an iCalendar feed. Parents can subscribe to that feed in Google Calendar, Apple Calendar or Outlook.
Can school staff update an Astro site without coding?
Yes. Add a git-based CMS like Decap CMS or Keystatic, or a headless CMS like Sanity or Storyblok. Staff fill in forms to publish news, events and letters, and the site rebuilds automatically.
What accessibility standard should a school website meet?
WCAG 2.1 AA is the common benchmark and is legally required for public schools in some countries, including under a 2024 ADA Title II rule in the US. Use semantic HTML, alt text, sufficient contrast, keyboard access and accessible documents.
How do I post urgent closure notices on a static school website?
Keep the alert message in a small data file that staff can edit through the CMS, render it as a banner on every page, and let the host rebuild, which typically takes a minute or two. Keep email and text messages as the main emergency channel.