payload-cms
Payload 3 and Next.js website starter with a layout builder, live preview, SEO tools and Postgres
Multi-language static Astro website with a separate Payload CMS, SEO tooling, live preview and redirects
Sets up a static Astro website and a Payload CMS as two separate projects, intended for deployment on Vercel. The CMS uses the MongoDB adapter, S3-compatible media storage and the official SEO plugin, with path generation for multi-language pages. The site is pre-rendered at build time, with a server-rendered preview route for live preview. It requires pnpm, a MongoDB database and environment files in both folders.
A fully featured template for building performant and scalable content-driven websites with Payload CMS and Astro.
This repository is a GitHub template: create your own copy of it in one click.
Create a repository from this templateThis is a fully featured template for building performant and scalable content-driven websites with Payload CMS and Astro.
This template is built for multi-language websites and includes SEO metadata, path generation, breadcrumbs, alternate language paths, redirects, media hosting, live preview, Plausible Analytics, robots.txt, and automatic sitemap generation.
[!NOTE] This template is still under active development. Features may change, and some functionality may not be fully stable or documented. I welcome feedback and suggestions for improvements.
Follow these steps to set up the project for local development:
Clone the repository:
git clone https://github.com/jhb-software/payload-astro-template.git
Open two terminals in a split view. One for the Astro website and one for the Payload CMS.
In both terminals install the dependencies using pnpm i.
Create a .env file in both the cms and web folders. You can use the .env.example files as a reference in both folders which contain descriptions for each varialbe.
Generate and set a secure secret key for the CMS:
PAYLOAD_SECRET in the CMS .env fileSet up MongoDB (if using MongoDB adapter):
Now you can start the development servers with pnpm dev in both terminals. Start with the CMS and then the website.
The CMS comes with a seed script to populate the database with some example data. To run it, uncomment the code inside the onInit function of your payload.config.ts file.
When adapting this template for your project, consider the following steps:
Update the CMS base configuration:
websiteName, csrf and resend configuration information in payload.config.ts to match your project detailsUpdate the website base configuration:
websiteConfig in web/src/config.ts with your project detailsweb/public directoryCustomize the CMS:
cms/src/collections to match your content needscms/src/blocks to match your content needsAdapt the website:
web/src/layout/collectionsweb/src/components/blocksweb/src/schema.tsNeed help deploying the system or going live? Contact me via email or X to discuss your project requirements and get expert assistance.
This section outlines the key architectural decisions made when building this template. While the template suggests specific approaches for building and hosting the system, you can adapt these to your specific needs.
To improve performance and SEO, this template uses a static Astro website. All pages are pre-rendered at build time and served as static files. To enable previewing changes made in the CMS (Payload Live Preview), this template includes a special preview route that server-side renders (SSR) the pages. More information on the Live Preview feature can be found in the Live Preview section section of this README.
The Astro app could be configured to server-side render all pages on demand with some modifications. To optimize performance, I recommend using Vercel Incremental Static Regeneration (ISR) to benefit from caching and automatically regenerate specific pages when content is added or updated in the CMS.
The template is designed to deploy the website and CMS as separate projects on Vercel. Since Payload runs on Next.js, this provides the simplest and best developer experience for deployment. The Astro app uses the Vercel adapter for deployment.
You can modify the setup to deploy both projects on another provider or self-host them if desired.
Since the website and CMS are deployed as separate projects, I recommend hosting your CMS on a subdomain of your website (e.g., cms.mywebsite.com). This creates a clean separation between the projects and maintains a clear URL structure.
The template uses the Payload MongoDB adapter, but you can use any other database adapter supported by Payload. For database hosting, MongoDB Atlas offers a simple and scalable solution.
The template uses the official @payloadcms/storage-s3 plugin to store media in any S3-compatible bucket. Hetzner S3 Object Storage is a cost-effective default, but the same configuration works with AWS S3, Cloudflare R2, MinIO, etc. — just set S3_ENDPOINT and S3_REGION accordingly.
For projects with larger budgets, I recommend using an image service with CDN and transformation capabilities like Cloudinary. Plugins are available for integrating Cloudinary with Payload.
/media endpointAlthough uploads are stored in S3, media is served from the Astro website at /media/*, not from the CMS or the bucket directly. The web/vercel.json file declares a Vercel rewrite that proxies /media/:path* to the S3 bucket and attaches long-lived Cache-Control headers; the CMS's generateFileURL hook (cms/src/collections/Media.ts) ensures every uploaded file is stored with a ${NEXT_PUBLIC_FRONTEND_URL}/media/<filename> URL, so the frontend can render media.url directly without any rewriting at render time.
Reasons for this indirection:
Cache-Control headers are set in vercel.json and benefit from Vercel's CDN. Cache headers no longer need to be configured on the storage adapter.S3_* env vars; existing image URLs in the database stay valid because they point at /media/* on the frontend, not at the bucket directly.The template integrates Plausible Analytics for website analytics. Plausible is a privacy-friendly analytics tool that doesn't track users across websites. You can easily modify or remove this to use a different analytics solution.
The template is designed with cost-effectiveness and scalability in mind. The static website ensures minimal hosting costs and excellent scalability. The CMS deployment on Vercel is cost efficient and scalable, as is MongoDB Atlas for database hosting. Since the site is static, database load occurs only during CMS updates or website builds, not during regular site visits.
Most components can be deployed using free tiers to get started.
Here's an overview of typical costs for a small to medium-sized website:
For reference, the jhb.software website operates on exactly this setup at these costs.
The CMS is configured to contain all basic features you need for a website.
The official SEO plugin is used to add metadata fields to all pages, including title, description, and social media metadata.
The Payload pages plugin is used to automatically generate paths, breadcrumbs, and alternate language paths for all pages. Documents from multiple collections can be nested to create hierarchical page structures.
The template includes an API Keys collection that enables token-based authentication for external consumers. This serves two purposes:
Authorization header.agent type can be issued to AI agents or automation tools, giving them scoped access to the CMS without sharing user credentials.API keys are managed via the CMS admin panel and are restricted to admin users only. Each key has a type field (website or agent) to categorize its intended use.
A dedicated collection for managing redirects, allowing you to handle old paths and maintain SEO when restructuring your site.
The Astro website is fully static, so the CMS includes the Vercel Deployments plugin to let content editors monitor the frontend's Vercel project and trigger a redeploy with a single click. The plugin registers a dashboard widget that shows the active and latest production deployment and exposes authenticated API endpoints for triggering deployments programmatically.
See the cms/src/payload.config.ts file for the plugin configuration.
The CMS uses the Alt text plugin to AI-generate alt texts for uploaded images via OpenAI. The plugin also registers an "Alt text health" dashboard widget that shows alt text coverage across the media collection and links to images that are still missing alt texts.
See the cms/src/payload.config.ts file for the plugin configuration.
Real-time preview functionality allows content editors to see changes before publishing, improving the content creation workflow.
Comprehensive SEO optimization including meta tags, Open Graph tags, Twitter Cards, and canonical URLs.
Automatic generation of JSON-LD structured data to help search engines understand your content better.
Privacy-friendly analytics integration with Plausible for tracking website performance without compromising user privacy.
Dynamic sitemap generation that updates automatically as you add or modify content, helping search engines discover your pages.
Automatically generated robots.txt file to control search engine crawling behavior.
Server-side redirects handled through the Vercel adapter for fast, SEO-friendly URL redirections.
Automatic generation of alternate language paths for multi-language support, ensuring proper hreflang implementation for international SEO.
If you want to contribute to this project, feel free to fork the repository and create a pull request. I am happy to receive feedback and suggestions for improvements.
If you need assistance with setting up this tech stack or Payload and Astro in general, feel free to contact me via email or X.
If you find this project helpful and would like to support its continued development, consider supporting me via the link below. Your support helps maintain and improve this and my other open-source projects:
Payload 3 and Next.js website starter with a layout builder, live preview, SEO tools and Postgres
Next.js website template with a layout builder, blog, search, SEO and live preview on Postgres

Payload website template with a Next.js frontend, layout builder blocks, blog, search, and live preview