To build a nonprofit website with Astro, model your programs, events and impact stories as content collections, link the donate button to a hosted payment page from a processor built for charities, add NGO structured data, and deploy the static build to a free host. Astro is a good fit for a nonprofit website because it ships plain HTML with no server to patch, so the site stays fast and cheap to run after the volunteer who built it moves on.
This guide walks through the pages a nonprofit site needs, the Astro 7 code for each part, and the choices that matter for small teams with no budget for maintenance.
Key Takeaways
- Keep the build static. A nonprofit site rarely needs server rendering, and static hosting is free on Cloudflare Pages, Netlify and GitHub Pages.
- Put programs, events and stories in content collections so non-developers can add a Markdown file instead of editing layouts.
- Never handle card data yourself. Link the donate button to a hosted checkout or embed from a donation provider.
- Add
NGOJSON-LD on the home page andEventJSON-LD on public events.- Treat accessibility as a requirement: many donors and volunteers browse on older phones and with assistive tech.
What a nonprofit website needs
Most nonprofit sites answer the same five questions for visitors: what you do, who it helps, how money is used, how to help, and how to get in touch. That maps to a small, stable set of pages.
| Page | Purpose | Astro source |
|---|---|---|
| Home | Mission, one key number, primary donate and volunteer actions | src/pages/index.astro |
| Programs | List and detail page for each program | programs collection |
| Impact / stories | Case stories with photos and outcomes | stories collection |
| Events | Upcoming fundraisers, drives, open days | events collection |
| Get involved | Volunteer, partner, fundraise | src/pages/get-involved.astro |
| Donate | Explains where money goes, links to the payment page | src/pages/donate.astro |
| About | Team, board, annual reports, registration number | src/pages/about.astro |
| Contact | Address, email, form | src/pages/contact.astro |
Annual reports and financial statements matter more than most teams expect. Donors and grant reviewers look for them, so give them a permanent URL like /about/reports/ and keep old PDFs in public/reports/ rather than deleting them.
Start the Astro project
Create a fresh project, or start from a theme that already has these pages:
# Terminal
npm create astro@latest nonprofit-site
cd nonprofit-site
npm run dev
The minimal template gives you src/pages/index.astro and nothing else, which is fine if you have time to design every page. If you’d rather start with a finished layout, the Astro community and nonprofit themes category has 25 themes at the time of writing, including Benevola, which ships Get Involved, Programs and Projects pages, and Care Hands, a charity and donation template with a donation page. Free options exist too: Astro’s own starter templates and the community listings at astro.build/themes are a reasonable place to look if your budget is zero.
Whichever route you take, the getting started docs cover cloning and running a theme locally.
Model programs, events and stories as collections
Content collections keep the structure in one schema file and the words in Markdown. A volunteer can add a new event by copying a file, and the build fails loudly if a required field is missing.
// src/content.config.ts
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
const programs = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/programs' }),
schema: ({ image }) =>
z.object({
title: z.string(),
summary: z.string().max(200),
cover: image(),
coverAlt: z.string(),
order: z.number().default(0),
}),
});
const events = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/events' }),
schema: z.object({
title: z.string(),
start: z.coerce.date(),
end: z.coerce.date().optional(),
location: z.string(),
registerUrl: z.string().url().optional(),
}),
});
const stories = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/stories' }),
schema: ({ image }) =>
z.object({
title: z.string(),
program: z.string(),
pubDate: z.coerce.date(),
photo: image().optional(),
photoAlt: z.string().optional(),
}),
});
export const collections = { programs, events, stories };
Note the import of z from astro/zod. Importing z from astro:content still works in Astro 7 but is deprecated. The image() helper validates that a cover image exists and lets <Image /> optimize it at build time. For a deeper walkthrough, see the Astro content collections guide.
A single event file looks like this:
---
# src/content/events/winter-coat-drive.md
title: "Winter coat drive"
start: 2026-12-05T10:00:00
end: 2026-12-05T15:00:00
location: "Riverside Community Hall"
registerUrl: "https://example.org/volunteer-signup"
---
Bring clean coats in any size. Volunteers sort and pack from 9:30.
Show upcoming events only
Events go stale quickly. Filter by date at build time and schedule a daily rebuild so last week’s fundraiser drops off without anyone editing the site.
---
// src/pages/events/index.astro
import { getCollection } from 'astro:content';
import BaseLayout from '../../layouts/BaseLayout.astro';
const now = new Date();
const upcoming = (await getCollection('events'))
.filter((e) => (e.data.end ?? e.data.start) >= now)
.sort((a, b) => a.data.start.getTime() - b.data.start.getTime());
const fmt = new Intl.DateTimeFormat('en-US', { dateStyle: 'medium', timeStyle: 'short' });
---
<BaseLayout title="Events" description="Upcoming drives, fundraisers and open days.">
<h1>Upcoming events</h1>
{upcoming.length === 0 && <p>No events scheduled right now. Check back soon.</p>}
<ul>
{upcoming.map((e) => (
<li>
<h2>{e.data.title}</h2>
<p><time datetime={e.data.start.toISOString()}>{fmt.format(e.data.start)}</time> at {e.data.location}</p>
{e.data.registerUrl && <a href={e.data.registerUrl}>Register to help</a>}
</li>
))}
</ul>
</BaseLayout>
Most static hosts can trigger a rebuild from a cron job or a scheduled GitHub Action. A once-a-day build is plenty for an events list.
Build the donate flow without touching card data
The donate page should explain what a gift does, then send people to a payment page you don’t host. That keeps you out of PCI scope and means there’s no payment code in your repo to keep patched.
Common options are a hosted donation form from a charity-focused platform, a Stripe Payment Link, or a PayPal donate button. All three give you a URL or a small embed. A plain link is the simplest and fastest:
---
// src/components/DonateButton.astro
interface Props {
href: string;
label?: string;
}
const { href, label = 'Donate' } = Astro.props;
---
<a class="donate" href={href} rel="noopener">{label}</a>
<style>
.donate {
display: inline-block;
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
background: var(--color-accent, #0f766e);
color: #fff;
font-weight: 600;
text-decoration: none;
}
.donate:focus-visible {
outline: 3px solid #111;
outline-offset: 2px;
}
</style>
Put the button in the header and at the end of every program and story page. On the donate page itself, show suggested amounts with what each one pays for, a line about tax deductibility if it applies in your country, and your registration number. If a provider only offers an embed script, load it on the donate page only, not site-wide, so every other page stays free of third-party JavaScript.
Volunteer and contact forms work the same way on a static site: post to a form backend or your host’s built-in form handling. The static contact forms guide compares the options.
Add NGO structured data
Search engines use structured data to understand who you are. Add an NGO object on the home page with your legal name, logo, address and social profiles.
---
// src/components/OrgSchema.astro
const schema = {
'@context': 'https://schema.org',
'@type': 'NGO',
name: 'Riverside Community Trust',
url: Astro.site?.href,
logo: new URL('/logo.png', Astro.site).href,
email: '[email protected]',
address: {
'@type': 'PostalAddress',
streetAddress: '12 Mill Lane',
addressLocality: 'Riverside',
postalCode: 'RV1 2AB',
addressCountry: 'GB',
},
sameAs: ['https://www.linkedin.com/company/example'],
};
---
<script type="application/ld+json" set:html={JSON.stringify(schema)} />
Astro.site is only set if you configure site in astro.config.mjs, so do that first. Public events can carry Event markup with startDate, location and organizer. The JSON-LD structured data guide shows how to generate both from collection data, and the schema.org NGO type lists every property.
Accessibility and performance checks
Nonprofit audiences are broad, and many funders now ask about accessibility. A few habits cover most of it:
- Use real headings in order, one
h1per page. - Give every photo meaningful
alttext. Astro’s<Image />component errors at build time ifaltis missing, which helps. - Keep text contrast at WCAG AA or better, especially on photo hero sections. Add a dark overlay rather than placing white text on a busy image.
- Make the donate link a real link, not a JavaScript click handler, so it works with a keyboard and without scripts.
- Use the
<Image />component fromastro:assetsfor every content photo so it is resized and served in modern formats.
---
// src/pages/programs/[id].astro
import { getCollection, render } from 'astro:content';
import { Image } from 'astro:assets';
import BaseLayout from '../../layouts/BaseLayout.astro';
import DonateButton from '../../components/DonateButton.astro';
export async function getStaticPaths() {
const programs = await getCollection('programs');
return programs.map((p) => ({ params: { id: p.id }, props: { program: p } }));
}
const { program } = Astro.props;
const { Content } = await render(program);
---
<BaseLayout title={program.data.title} description={program.data.summary}>
<Image src={program.data.cover} alt={program.data.coverAlt} widths={[480, 960, 1440]} sizes="100vw" />
<h1>{program.data.title}</h1>
<Content />
<DonateButton href="https://example.org/donate" label="Fund this program" />
</BaseLayout>
Photos are usually the heaviest thing on a charity site, so this one component does most of the performance work.
Let non-developers update the site
The person who builds the site is rarely the person who updates it. You have three practical paths:
- Markdown in GitHub. Staff edit files in the GitHub web editor. Free, and every change is versioned, but it suits people comfortable with a text editor.
- Git-based CMS. Tools like Decap CMS or Keystatic add a form-based editor on top of the same Markdown files. No database, and your content stays in the repo.
- Hosted headless CMS. Sanity, Storyblok and similar tools give a polished editor and many offer nonprofit discounts. You add an API dependency and usually a rebuild webhook.
For most small charities, a git-based CMS is the sweet spot: the site stays static and free to host, and staff never see code.
Deploy for free
Run npm run build and you get a dist/ folder of static files. Cloudflare Pages, Netlify and GitHub Pages all host static Astro sites on free plans, and all three connect to a GitHub repo and rebuild on every push. Check each host’s current terms; some free plans limit commercial use, which can matter if you sell merchandise. The static deployment docs cover each host step by step, and the official Astro deployment guides list more.
Point your domain, turn on HTTPS (all three do it automatically), and set up the daily rebuild for the events list. After that, the site needs almost no maintenance beyond content updates and an occasional npm update.
FAQ
Is Astro good for nonprofit websites?
Yes. Astro builds static HTML by default, so a nonprofit site can be hosted for free with no server, database or plugins to patch. Content collections let staff add programs, events and stories as Markdown files, and the pages load fast on low-end phones.
How do I accept donations on a static Astro site?
Link your donate button to a hosted payment page from a donation platform, Stripe Payment Links or PayPal. The payment provider handles card data and receipts, and your Astro site stays static. If the provider gives you an embed script, load it only on the donate page.
How much does it cost to run a nonprofit website built with Astro?
The hosting can be free on Cloudflare Pages, Netlify or GitHub Pages, so the main costs are your domain name and any paid tools you choose, such as a hosted CMS or a premium theme. Payment providers charge per-transaction fees on donations.
Can volunteers update an Astro site without coding?
Yes, if you add a git-based CMS such as Decap CMS or Keystatic, or a hosted headless CMS. Volunteers fill in forms, and the CMS commits Markdown files that trigger a rebuild. Without a CMS, they can still edit Markdown files directly in GitHub.
Which schema type should a nonprofit website use?
Use the schema.org NGO type for the organization on your home page, with name, logo, address and social profiles. Add Event markup to public events and BlogPosting to news or impact stories.