Astro Templates as a Product: Scalable Layouts for Blogs, Landing Pages, and CMS
Astro enables developers to create high-performance, modular templates that scale. Whether you’re building a blog, a documentation site, or a CMS-powered landing page, Astro provides the flexibility to structure and reuse layouts without breaking architecture.
Let’s explore how to treat Astro templates as products: customizable, reusable, and ready for client projects or growth-driven marketing.
📐 Modular Page Layouts for Different Content Types
Structure reusable layouts in src/layouts/:
src/layouts/
├── BlogLayout.astro
├── DocLayout.astro
├── LandingLayout.astro
Example:
---
// BlogLayout.astro
const { title, description } = Astro.props;
---
<SEO title={title} description={description} />
<main class="prose mx-auto">
<header><h1>{title}</h1></header>
<slot />
</main>
Now any blog post can import and reuse it, ensuring UI consistency and reducing code duplication.
🧠 Encapsulating SEO and UI into Components
Keep logic modular with components like:
<SEO>for metadata and social tags<Navbar>,<Footer>,<LanguageSwitcher>for UI<Hero>,<CallToAction>,<NewsletterForm>for landing pages
Each component lives in src/components/ and is driven by props, making them portable across projects.
🔁 Page Generation with import.meta.glob() and getStaticPaths()
Astro makes static generation scalable with built-ins:
// In blog/[slug].astro
export async function getStaticPaths() {
const posts = Object.values(await import.meta.glob('../../content/blog/*.md', { eager: true }));
return posts.map(post => ({
params: { slug: post.slug },
props: { post }
}));
}
Use import.meta.glob for bulk content ingestion, ideal for blog posts or product pages.
🌍 i18n and Metadata Localization
Make your template multilingual:
- Define locale files in
src/locales/en.json,ru.json, etc. - Inject metadata dynamically:
import en from '../locales/en.json';
const { title, description } = en.blogPost;
Or use runtime i18n libraries like astro-i18next to manage routes and text dynamically.
Add localized og:title, twitter:title, and <html lang="...">.
🌐 Headless CMS Integration (Sanity, Strapi, etc.)
External CMSs can power content via API:
const res = await fetch("https://your-cms.io/api/posts");
const posts = await res.json();
Then map that to pages and props in your layout. Combine dynamic routes with SSR/SSG strategies if needed.
Recommended CMSs:
🎨 Tailwind CSS or UnoCSS for Design System
Astro works seamlessly with both:
Tailwind
npm install -D tailwindcss
npx tailwindcss init
Use utility classes like:
<section class="py-12 px-6 bg-gray-100">
<h2 class="text-3xl font-bold">Built for Performance</h2>
</section>
UnoCSS (if you prefer atomic mode)
npm install -D unocss
In astro.config.mjs:
import UnoCSS from 'unocss/astro';
export default {
integrations: [UnoCSS()]
}
🔧 Why This Template Is Built to Scale
- ✅ Easy to clone and customize for new clients
- ✅ Built-in support for blogs, docs, and landing pages
- ✅ Modular SEO & metadata management
- ✅ i18n-ready
- ✅ CMS-integratable
- ✅ Utility-first styling (Tailwind or UnoCSS)
You don’t need to rewrite code every time—just extend, override, or plug in what you need.
✅ Conclusion
Treating Astro templates as a product lets you ship faster, scale smarter, and respond to content or client needs without architectural rewrites. With modular layouts, localization, and CMS compatibility, your Astro setup becomes the foundation for any marketing, editorial, or SaaS site.
Build once. Customize endlessly. Astro makes it easy.