💡 Business Value: Save 20+ hours of development time with this production-ready template that delivers enterprise-grade performance and SEO optimization for small businesses and developers.
A production-ready blog starter template built with Astro and Contentful CMS. Features interactive multi-tag filtering, beautiful responsive design, and seamless Cloudflare Pages deployment.
🚀 Live Demo: View the live site
⚡ Performance: 95+ Lighthouse scores across all metrics
🌍 Global CDN: Deployed on Cloudflare Pages for maximum speed
- Interactive Multi-Tag Filtering - Click multiple tags to filter blog posts without page refreshes
- Beautiful Responsive Design - Mobile-first approach with smooth animations
- Professional Demo Content - 5 comprehensive blog posts about Astro and Contentful
- Image Optimization - Automatic image resizing and lazy loading
- SEO Ready - Built-in meta tags, Open Graph, and structured data
- Astro 4.x - Lightning-fast static site generation
- Contentful CMS - Headless content management via REST API
- TypeScript - Full type safety and developer experience
- Tailwind CSS - Utility-first styling with custom design system
- Cloudflare Pages - Optimized for global CDN deployment
- Smooth Animations - Fade and scale effects during filtering
- Visual Feedback - Active tag highlighting and result counts
- URL Synchronization - Shareable filtered URLs
- Keyboard Accessible - Full keyboard navigation support
- 📱 Mobile Optimized - Perfect touch targets and readable text
- 💻 Desktop Enhanced - Rich layouts with optimal spacing
- 🔄 Fluid Breakpoints - Seamless transitions between screen sizes
- ⚡ Performance Focused - Optimized images and layouts for all devices
Perfect on every device - From phones to large desktop screens, your content looks stunning everywhere.
git clone https://github.com/djmartin2019/Astro-Contentful-Starter-Project.git
cd Astro-Contentful-Starter-Project
npm install# Copy environment template
cp .env.example .env
# Run the automated setup (creates content types + adds demo content)
npm run contentful:initThat's it! The automated setup will:
- ✅ Create your Contentful space content types
- ✅ Add 5 professional blog posts about Astro and Contentful
- ✅ Set up featured images and metadata
- ✅ Configure all necessary fields
npm run devVisit http://localhost:4321 to see your blog in action!
If you prefer to set up Contentful manually or want to understand the process:
- Go to contentful.com and sign up
- Create a new space (choose "Empty space")
- Note your Space ID (found in Settings → General settings)
- Go to Settings → API keys
- Create a new Content Delivery API token
- Go to Settings → API keys → Content management tokens
- Create a new Personal access token (for content management)
Edit your .env file with your Contentful credentials:
# Contentful Configuration
CONTENTFUL_SPACE_ID=your_space_id_here
CONTENTFUL_DELIVERY_TOKEN=your_delivery_token_here
CONTENTFUL_MANAGEMENT_TOKEN=your_management_token_here
CONTENTFUL_ENVIRONMENT=master# This creates the required content types in Contentful
npm run contentful:setupWhat gets created:
- Blog Post content type with fields:
- Title (Short text)
- Slug (Short text, unique)
- Excerpt (Long text)
- Content (Rich text)
- Featured Image (Media)
- Author (Short text)
- Publish Date (Date & time)
- Tags (Short text, list)
# This adds 5 professional blog posts about Astro and Contentful
npm run contentful:seedDemo content includes:
- 5 comprehensive blog posts with realistic content
- Professional featured images from Unsplash
- Proper metadata and SEO optimization
- Multiple tags for testing the filtering system
Try it yourself: Live Demo
- Click any tag to filter posts instantly
- Select multiple tags to find posts matching any of them
- Smooth animations with fade and scale effects
- URL synchronization - share filtered results
- Visual feedback - active tags are highlighted
- Result counting - see how many posts match your filters
The seed script creates 5 comprehensive blog posts:
- 🚀 Getting Started with Astro - Introduction to Astro's islands architecture
- 📝 Contentful CMS Guide - Complete guide to headless content management
- ⚡ Astro + Contentful Integration - Building lightning-fast sites
- 🎯 Headless CMS Benefits - Why headless is the future
- ☁️ Cloudflare Pages Deployment - Step-by-step deployment guide
Each post includes:
- ✅ Realistic content with code examples and best practices
- ✅ Professional metadata (author, publish date, tags)
- ✅ High-quality featured images from Unsplash
- ✅ SEO-optimized excerpts and descriptions
- ✅ Multiple tags for testing the filtering system
- ✅ Responsive design that looks great on all devices
This template is optimized for Cloudflare Pages with zero configuration needed:
- ⚡ Global CDN - Lightning-fast loading worldwide
- 🆓 Free tier - Perfect for personal projects and demos
- 🔧 Zero config - No server setup required
- 📱 Mobile optimized - Automatic image optimization
- 🔒 HTTPS included - SSL certificates managed automatically
Note: After clicking the button, you'll still need to:
- Set up your Contentful environment variables in Cloudflare Pages dashboard
- Run
npm run contentful:initto add demo content
- Connect your repository to Cloudflare Pages
- Set build settings:
- Build command:
npm run build - Build output directory:
dist - Node.js version:
18or higher
- Build command:
- Add environment variables in Cloudflare Pages dashboard:
CONTENTFUL_SPACE_ID- Your Contentful space IDCONTENTFUL_DELIVERY_TOKEN- Your Contentful delivery tokenCONTENTFUL_ENVIRONMENT-master(default)
- Deploy! - Your site will be live in minutes
CONTENTFUL_SPACE_ID=your_space_id
CONTENTFUL_DELIVERY_TOKEN=your_delivery_token
CONTENTFUL_ENVIRONMENT=masterNote: You don't need CONTENTFUL_MANAGEMENT_TOKEN in production - that's only for the seed script.
src/
├── components/ # Reusable components
├── layouts/ # Page layouts
├── lib/ # Contentful client & helpers
├── pages/ # Astro pages
├── types/ # TypeScript types
└── styles/ # Global styles
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm run preview- Preview production build locallynpm run type-check- Check TypeScript types
npm run contentful:init- Complete setup (content types + demo content)npm run contentful:setup- Create content types onlynpm run contentful:seed- Add demo blog posts only
❌ "CONTENTFUL_SPACE_ID is not defined"
- Make sure you've copied
.env.exampleto.env - Verify your environment variables are set correctly
- Restart your development server after changing
.env
❌ "Contentful API error: 401 Unauthorized"
- Check your
CONTENTFUL_DELIVERY_TOKENis correct - Ensure the token has read permissions
- Verify your
CONTENTFUL_SPACE_IDmatches your space
❌ "Contentful API error: 404 Not Found"
- Run
npm run contentful:setupto create content types - Check that your space ID is correct
- Ensure you're using the right environment (usually
master)
❌ Images not showing
- The fallback system will show placeholder images
- For real Contentful images, ensure your content types are set up
- Check that featured images are published in Contentful
❌ Build fails on Cloudflare Pages
- Ensure all environment variables are set in Cloudflare Pages dashboard
- Check that your Contentful tokens have the correct permissions
- Verify your Node.js version is 18 or higher
- Check the logs - Look for specific error messages
- Verify setup - Run
npm run contentful:initto ensure everything is configured - Test locally - Make sure
npm run devworks before deploying - Check Contentful - Verify your content is published in the Contentful web app
- Colors & Branding: Update
tailwind.config.cjs - Typography: Modify font families in
src/layouts/Base.astro - Layout: Edit
src/layouts/Base.astrofor global layout changes - Components: Customize individual components in
src/components/
- Blog Posts: Add/edit content in Contentful web app
- Content Types: Modify fields in Contentful (requires re-seeding)
- Images: Upload new featured images in Contentful
- Tags: Add new tags in Contentful and they'll appear automatically
- Filtering Logic: Modify
src/pages/blog/index.astrofor different filtering behavior - Styling: Customize
src/styles/global.cssfor global styles - SEO: Update meta tags in
src/layouts/Base.astro - Performance: Optimize images and add caching strategies
- Astro Documentation - Learn Astro's islands architecture
- Contentful Documentation - Master headless CMS
- Cloudflare Pages - Deploy globally
- Tailwind CSS - Utility-first styling
- Astro Examples - More Astro templates
- Contentful Examples - Contentful integrations
- Cloudflare Examples - Edge computing examples
Found a bug or want to add a feature? Contributions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - feel free to use this template for your projects! See LICENSE for details.
If this project helped you, please give it a ⭐ on GitHub! It helps others discover this template.
Happy coding! 🚀