Verso: a marketing site for Astro and Sanity, with a page builder
A free marketing-site template: 19 page-builder sections with pictures in the insert menu, visual editing, SEO and a Cloudflare deploy.
Verso is a free template for a company or product website: a home page, a features page, pricing, about and a blog, every page built from sections in Sanity Studio. Editors add, remove and reorder sections, pick a layout for each, and see the page change beside the form in the Presentation tool. The site itself is Astro: every page is built ahead of time as a static file on Cloudflare Workers, so Sanity is only asked for content when the site is built or previewed.
Live demo: verso.themes.dev, this repository as it is, on its demo content.
It is the companion of Recto, our free blog template: the same Studio setup, visual editing and deploy, with the sections a marketing site needs on top.
The demo is an invented company, Fernway, which makes appointment software for small clinics. Every name, figure and quote in it is made up, and the photos are AI-generated.
Made by themes.dev, where you'll find more themes and sections for Astro, Next.js and Sanity.
What you get
- A page builder with 19 sections, each a native
.astrocomponent and a Sanity object type made from the same definition, so the Studio's fields always match what the component draws. The insert menu groups them (intro, content, proof, action) and shows a picture of each, so editors pick a section by how it looks. Every section has layouts, a tone (the page ground or a quiet band) and spacing. Give one an anchor to link to it (/pricing/#questions). - Pages: home, features, pricing, about and blog in the demo. Any page you create in the Studio gets its own
address (
/<slug>/) on the next build, with no code to change. - A blog: a paginated index, posts with a cover, byline, headings, lists, quotes, images with captions, tables and highlighted code, the author box and three more posts.
- Visual editing: the Studio's Presentation tool shows your drafts beside the form, and a click on a text in the
preview opens its field (
@sanity/astro, stega). - SEO: titles and descriptions, canonical links, Open Graph images drawn at build time for every page and post,
JSON-LD (website, organisation, blog posts, breadcrumbs), a sitemap, robots.txt, an RSS feed,
llms.txtand every post as Markdown (/blog/<slug>.md). - Speed and access: static HTML, self-hosted fonts with matched fallbacks, photos in WebP with their sizes, and almost no client JavaScript (the mobile menu, the pricing switch, the announcement's close button, the code blocks' copy button and the one-line dark-mode script). Text contrast is AA in light and dark.
- A newsletter sign-up that works without JavaScript and forwards each address as JSON to your email service, with a honeypot for bots.
- Deploys to Cloudflare Workers: the pages as static assets, the preview and the form in the same Worker.
The sections
| Section | Layouts | For |
|---|---|---|
| Announcement | bar | a line above the header (Site document) |
| Header | inline, centered | name, navigation, buttons, a menu on phones (Site document) |
| Footer | wordmark, cta, editorial, product, columns, stacked | link columns, legal line (Site document) |
| Hero | centered, split, stacked, overlay, code, poster, panel | the top of a page, with or without a photo |
| Page header | stacked, centered | the heading of a page without a hero |
| Logos | row, grid, marquee | customer or partner marks |
| Features | grid, cards, split, board, bento | what the product does, with icons |
| Steps | row, vertical, track | how it works, in order |
| Split | image-end, image-start, bleed | text beside a photo |
| Media | image, video, annotated | one large image or video |
| Stats | row, split, lead, band | figures with a label |
| Content | single, split, statement | longer text in blocks |
| Testimonials | single, grid, lead | quotes with name and role |
| Team | grid, list, portraits | people with role and photo |
| Pricing | cards, list, table | plans with a monthly and yearly price |
| FAQ | stacked, split, grid | questions that open and close |
| Posts | grid, list, featured | chosen posts, or the newest when left empty |
| Newsletter | inline, card, band | the sign-up form |
| Call to action | centered, split, panel, row | a heading and one or two buttons |
Want more sections? UI Pro adds 30 finished blocks to the same kind of Studio: pick them by picture, click the page to edit, and limits that warn editors before a heading outgrows its design.
Start
The quickest way is Sanity's CLI. It copies this repository, creates (or picks) a Sanity project and a dataset, makes
a read token and a write token, and writes frontend/.env.local and studio/.env for you:
npm create sanity@latest -- --template <this repository>Then, in the new folder:
pnpm seed # import the demo company into your dataset
pnpm dev # the site on http://localhost:4321 and the Studio on http://localhost:3333After the seed, remove SANITY_API_WRITE_TOKEN from frontend/.env.local: the site never needs it.
You can also clone the repository and follow Set up Sanity below.
Quick look
You need Node.js 22.12 or newer and pnpm (npm install -g pnpm).
pnpm install
pnpm dev:astro # http://localhost:4321Until you connect a Sanity project, the site shows the demo content from frontend/seed/. It reads that content with
the same GROQ queries it uses against Sanity, through groq-js. This is for a first look only: a production build
needs a Sanity project, and stops with a message when there is none. To build the demo content anyway (for a static
preview of the design), set SANITY_FIXTURE=1:
SANITY_FIXTURE=1 pnpm build
pnpm preview # the built site, in Cloudflare's runtimeSet up Sanity
Sanity's free plan is enough. It takes about ten minutes.
Create a project. Sign in at sanity.io/manage, choose Create new project and pick the Free plan. Note the project ID. Create a dataset called
productionwith public visibility. Published content is then read without a token, and drafts stay private either way.Tokens. In the project, go to API › Tokens › Add API token. Create one with Editor rights (for the import in step 4) and one with Viewer rights (for the build and the preview).
Settings.
- Copy
frontend/.env.exampletofrontend/.env.local. Fill inPUBLIC_SANITY_PROJECT_ID,SANITY_API_WRITE_TOKEN(the Editor token) andSANITY_API_READ_TOKEN(the Viewer token). - Copy
studio/.env.exampletostudio/.envand fill inSANITY_STUDIO_PROJECT_ID.
- Copy
Import the demo content:
pnpm seedThis uploads the demo photos and logos and writes the Site document, five pages and four posts. Running it again replaces them and touches nothing else. Afterwards, remove
SANITY_API_WRITE_TOKENfromfrontend/.env.local, because the site never needs it.CORS. In the project, go to API › CORS origins and add two addresses:
http://localhost:3333with Allow credentials (the Studio on your computer) andhttp://localhost:4321without (the site). The logos section draws each logo as a CSS mask, which the browser fetches with anOriginheader, and Sanity's image CDN refuses such a request from an address that is not on this list: without it the logos stay blank.Run both:
pnpm dev # the site on http://localhost:4321 and the Studio on http://localhost:3333
Publishing
The site is static: a published change shows once the site is built again. Run pnpm deploy:cf, or let your CI build
on a schedule or on a Sanity webhook (API › Webhooks, on create, update and delete, filter
_type in ["page", "post", "siteSettings"]) that starts a build in your CI. The preview never waits: it reads drafts
as you type.
Editing in the Studio
- Site (one document): the announcement bar, the header (name, navigation, button), the footer (link columns, feed, legal line) and the organisation behind the site, for search engines.
- Pages: each page has a title, a path, a description and its Sections. You can add, remove and reorder
sections. Each one has a Layout and a Tone. Give a section an Anchor to link to it: the newsletter's anchor
questionson the pricing page makes/pricing/#questionsjump to it. - Posts: title, slug, date, excerpt, cover, author (name, photo, role, bio), up to three tags, and the body.
| Address | Page document (slug) | Notes |
|---|---|---|
/ | home | its title is used in full |
/<slug>/ | any other page | features, pricing and about in the demo; a new page appears on the next build |
/blog/ | blog | its first section (the page header), then the posts, then its other sections |
/blog/<slug>/ | a post | with three more posts and the blog page's newsletter section |
/privacy/, /thanks/, 404 | files in frontend/src/pages/ | the privacy page holds a sample text for the demo company |
A new page needs nothing but the Studio: create a page, give it a slug, add sections and publish. The next build
makes /<slug>/, and the preview shows it at once. Add it to the header or footer in the Site document. The slugs
home, blog, privacy, thanks, preview, api and og are taken by the site's own routes.
The privacy page is a sample written for the demo company, not legal advice. A note at the top says so while the
page passes isSample. Rewrite it for your own site, have it checked, then remove isSample.
Visual editing
The Studio's Presentation tool shows the site next to the form, with your unpublished drafts, and refreshes as you type. A click on a heading, a paragraph or a name in the preview opens that field.
The public pages are static files, so drafts are shown under /preview/: the same pages, rendered on request in
the Worker with drafts and with stega (invisible markers in each text that point at its field). This is how it fits
together:
- Presentation opens
/api/draft-mode/enable/with a one-time secret. The Worker checks it against your project with the read token (@sanity/preview-url-secret), sets a signed cookie (HMAC with the read token, eight hours) and goes to/preview/…. /preview/…renders the page with drafts only while that cookie is valid; without it, it sends you to the published page. Links inside the preview stay in it (frontend/src/middleware.ts).@sanity/astro/visual-editingdraws the overlays and reloads the page when a document changes. Its code is only on preview pages, never on the public site.
It needs three settings:
SANITY_API_READ_TOKENwhere the site runs (a Worker secret);SANITY_STUDIO_PREVIEW_URLinstudio/.env, set to the site's address;SANITY_STUDIO_URLwhen you build the site, set to the Studio's address. That is the only site allowed to show yours in a frame, and where a click in the preview goes.
Stega is added only to the words a reader sees (headings, leads, titles, excerpts, names, the body text). Layouts,
tones, links, slugs and dates stay plain, so the preview renders exactly like the published page. The list is
STEGA_FIELDS in frontend/src/lib/data/index.ts.
What's where
studio/ Sanity Studio (its own app in this workspace)
sanity.config.ts the Studio: structure, Presentation, Vision
presentation.ts which page shows which document (under /preview/)
schema/ generated/ (sections, pages, posts, Site) plus this template's additions in index.ts
static/sections/ the insert menu's picture of each section (<type>.webp, 900 × 600)
frontend/ the Astro site
astro.config.mjs static output, the Cloudflare adapter, @sanity/astro, fonts, the security headers
wrangler.jsonc the Worker and its static assets
src/pages/ index (home), [slug] (every other page), blog/, plus the feed, sitemap, robots, llms.txt, Open Graph images, the
preview (preview/[...path].astro) and the API routes (api/)
src/views/ the page bodies, shared by the static pages and the preview
src/components/ the site layout (head, header, footer), the page builder, the legal page shell
src/kit/ our Astro kit: Seo, JsonLd and schema.ts, Time, PortableText (astro-portabletext) and its parts
src/lib/ content.ts (what pages read), queries.ts (GROQ), views.ts (what each page needs),
latest.ts (empty Posts sections), data/ (Sanity fetch and the demo fixture), preview.ts
(the preview cookie), forms.ts, markdown.ts, seo.ts, og/
src/sections/ the sections (.astro), their parts and recipes, the generated queries, their stylesheets
src/styles/ global.css, presets/verso.css (every colour, font and size), prose.css
seed/ the demo content in Sanity's format (pnpm seed imports it)
public/images/ the demo photos (covers, the team): replace them with your own
public/demo/logos/ the demo company's invented customer logos
tools/ lint.mjs (the design rules), favicon.mjs
tests/ the form handler, and every query run against the demo contentCustomising the look
Everything the site draws comes from the custom properties in frontend/src/styles/presets/verso.css, under shadcn's
token names:
- Colours:
--background,--foreground,--card,--muted,--muted-foreground,--secondary,--accent,--border,--input,--primary(links and the main button),--primary-foreground,--destructive,--ring, plus the section library's--border-strong,--primary-softand--primary-soft-foreground. The:rootblock holds the light values and.darkthe dark ones.[data-tone='muted']is the quiet band: the page ground with 40% of--mutedin it, no more. - Type:
--font-sans(Geist, used for headings too),--font-mono(Geist Mono), and one scale from--text-size-xs(12px) to--text-size-display(60px), plus--text-size-herofor the home page's headline. Every size is a step on Tailwind's scale, and each heading size carries its own leading and tracking (60px and up 1.0 and -0.03em, 40 to 59px 1.04 and -0.024em, 28 to 39px 1.08 and -0.018em, 22 to 27px 1.15 and -0.01em, smaller 1.25). The post body is 18px at 1.6 in a column under 60 characters (--measure, inprose.css). - Space and shape:
--space-section,--space-gap,--size-container,--radius(the others follow from it). Buttons and fields are 36px tall with 14px text. - Phones: the
@media (width < 40rem)block.
The design rules are checked by pnpm lint: colours only from the preset, no serif fonts, type only on the scale (no
text-[15px], no clamp()), no inverse or dark bands, no gradients or patterns, one <h1> per page, every <img>
with alt, width and height, and demo images as WebP photos (logos as SVG). Keep text at 4.5:1 contrast against its background, and
use the token classes in your own markup (bg-card, text-muted-foreground, rounded-card, text-size-lg).
Tailwind's own palette and type scale are switched off on purpose.
Photos. The demo photos are AI-generated placeholders: replace them with your own in the Studio. A cover is drawn
at 16:9 (the files are 1536×864) and a portrait square (128×128). Logos are SVG files 40 pixels high. The Sanity
CDN serves each at the size it is drawn. After changing the accent colour, run pnpm favicon for the icon.
Insert menu pictures. studio/static/sections/ holds a screenshot of each section from the demo, named after its
type (heroSection.webp), 900 × 600. After you change the look, replace them with screenshots of your own site, cut to
the same size; insertMenu in studio/schema/index.ts sets the groups and the grid.
Fonts are self-hosted from Fontsource (SIL Open Font License) through Astro's font API (fonts in
frontend/astro.config.mjs), which preloads them and sizes a fallback font to match. To change one, install its
package (pnpm --filter verso-astro-frontend add @fontsource-variable/<name>), point its src at the woff2 file and
update the stack in the preset. The Open Graph images use the static files of the same font
(frontend/src/lib/og/image.ts).
Dark mode follows the system setting: src/kit/components/ThemeScript.astro sets the dark class on <html>
before the first paint (or the reader's choice, saved as theme in local storage, if your site adds a switch).
The newsletter form
The sign-up posts to /api/newsletter/, a small endpoint in the Worker (frontend/src/pages/api/newsletter.ts),
handled by frontend/src/lib/forms.ts:
- The address goes as JSON to
FORWARD_URL: your email service's API, an automation tool or a webhook. The visitor then sees/thanks/. - Without
FORWARD_URLthe form fails closed: it answers 503 and accepts nothing. The log names the form, never the address. - A hidden honeypot field,
company_website, catches bots. A submission with it filled gets the normal answer and is dropped.
To use a newsletter provider's own form instead, set the section's Form action to its URL and add that origin to
form-action in the Content-Security-Policy in frontend/astro.config.mjs.
Deploy to Cloudflare
The pages, images and feeds are static assets on Cloudflare Workers, and the same Worker (Astro's Cloudflare adapter,
frontend/wrangler.jsonc) answers only /preview/…, /api/draft-mode/… and /api/newsletter/.
Log in once:
cd frontend && npx wrangler login.Add the secrets the Worker reads at request time:
npx wrangler secret put SANITY_API_READ_TOKEN npx wrangler secret put FORWARD_URLPut the build settings in
frontend/.env.local(or export them in the shell):PUBLIC_SANITY_PROJECT_ID,PUBLIC_SANITY_DATASET,SANITY_API_READ_TOKEN,SITE_URLandSANITY_STUDIO_URL.Build and deploy from the repository root:
pnpm deploy:cfAdd the site's address to your Sanity project's CORS origins (without credentials; the logos need it, see Set up Sanity), and set
SANITY_STUDIO_PREVIEW_URLinstudio/.envto it.
The 404 page, trailing slashes and the security headers (_headers, written by the build) are handled by Workers
static assets. To build in Cloudflare's own CI (Workers Builds) instead, connect the repository, set the root directory
to frontend, the build command to pnpm build, the deploy command to npx wrangler deploy, and the build variables
above.
Studio. Run pnpm studio:deploy for Sanity's free hosting (https://<name>.sanity.studio). Set
SANITY_STUDIO_PREVIEW_URL in studio/.env to the live site first, and add the live site to the project's CORS
origins.
Environment variables
The site (frontend/.env.example):
| Variable | When | ||
|---|---|---|---|
PUBLIC_SANITY_PROJECT_ID, PUBLIC_SANITY_DATASET | build | public | your project; empty: the demo content |
SANITY_API_READ_TOKEN | build and Worker | secret | a Viewer token: published content at build time, drafts in the preview |
SANITY_STUDIO_URL | build | your Studio's address, allowed to frame the site | |
SITE_URL | build | the site's address, for canonical links, sitemap, feed and Open Graph images | |
FORWARD_URL | Worker | secret | where newsletter sign-ups go |
SANITY_API_WRITE_TOKEN | pnpm seed only | secret | an Editor token; remove it after the seed |
SANITY_FIXTURE | build | 1 builds the demo content without a Sanity project |
The Studio (studio/.env.example): SANITY_STUDIO_PROJECT_ID, SANITY_STUDIO_DATASET, SANITY_STUDIO_PREVIEW_URL
(the site, http://localhost:4321 while you work), and SANITY_STUDIO_HOST for pnpm studio:deploy.
Security
- Only the project ID and dataset reach the browser. The read token is a server secret (
astro:env/server), used at build time and in the Worker, and the write token only bypnpm seed. - The preview turns on only through the Studio, which signs each request with a one-time secret; the cookie it sets is signed and expires.
- A Content-Security-Policy allows scripts, styles and fonts from the site itself, images from the site and Sanity's CDN, forms to the site, and framing only by your Studio. It is sent with the static pages and the Worker's answers.
Commands
Run them from the repository root.
| Command | |
|---|---|
pnpm dev | the site and the Studio together |
pnpm dev:astro / pnpm dev:studio | one of them |
pnpm build | production build of the site |
pnpm preview | the built site, locally, in Cloudflare's runtime |
pnpm seed | import the demo content into your dataset |
pnpm check | astro check for the site |
pnpm typecheck | TypeScript for the site and the Studio |
pnpm lint | the template's design rules |
pnpm test | the form handler, and every query run against the demo content |
pnpm favicon | draw the favicon in the preset's accent |
pnpm studio:deploy | deploy the Studio to Sanity's hosting |
pnpm deploy:cf | build and deploy the site to Cloudflare Workers |
pnpm validate | check the repository against Sanity's template rules |
License
MIT, see LICENSE. The fonts keep their own licenses (SIL Open Font License 1.1). The demo content and photos are
yours to replace; the photos are AI-generated and the logos invented.
How the page builder is put together, step by step: How to build a page builder in Sanity. More sections and full site themes for Astro, Next.js and Sanity: themes.dev.

