Astro + TinaCMS: Complete Integration, Visual Editing & Image Optimization Guide
What is Astro?
Astro is a web framework focused on delivering fast websites. It uses a component-based architecture and generates lightweight HTML, reducing the amount of JavaScript sent to visitors
TinaCMS is a Git-backed content management system that stores structured content in files inside your project repository.
Instead of hardcoding every piece of website content in Astro components, you define content fields in TinaCMS collections.
TinaCMS supports contextual visual editing. Editors can open a page in the CMS preview, select an editable element, and update its content through the editing interface.
For example, clicking a homepage heading can open its corresponding text field in the editor. The developer controls which fields are editable by connecting TinaCMS schema fields to rendered Astro elements.
Installing and Configuring TinaCMS with Astro in Local Development Mode
Install TinaCMS in an Existing Astro Project
Open your Astro project directory
cd my-astro-project</code>
The recommended approach for an existing Astro website is to use the TinaCMS initialization command.
npx @tinacms/cli@latest init
When you install and initialize TinaCMS in your Astro project, it automatically generates several configuration files and directories required for content management, GraphQL queries, and local development.
The important files are:
tina/config.ts Main CMS configuration
tina/collections/ Collection definitions, if organized separately
tina/__generated__/client.ts Generated GraphQL client
tina/__generated__/types.ts Generated TypeScript types
content/ Actual website content