Enable Blog Pages
The blog system is controlled by environment configuration:1
Environment Configuration
Add blog page configuration to your environment file:This enables both blog routes:
# .env.local or .env.production
ENABLE_BLOG=true/blog- Database-driven blog/blog/mdx- Static MDX blog
2
Verify Configuration
The boilerplate checks page enablement with:
// lib/utils.ts
import { PagesConst } from '@/env'
export function isPageEnabled(page: string): boolean {
return process.env[`ENABLE_${page}`] === 'true'
}
// Usage in pages
if (!isPageEnabled(PagesConst.BLOG)) {
return notFound()
}3
Development Server
Start your development server to see the blog:Available Routes:
pnpm devhttp://localhost:3000/blog- Database blog listhttp://localhost:3000/blog/mdx- MDX blog listhttp://localhost:3000/admin/blog- Admin dashboard (requires login)
Database Setup
For the database blog system, ensure your database includes the blog schema:1
Run Migrations
Apply database migrations to create blog tables:This creates the necessary tables:
pnpm db:migratepost- Main post datapost_translation- Multi-language contentcategory- Content categorieshashtag- Content tagspost_hashtag- Tag associations
2
Seed Sample Data (Optional)
Add sample blog content for development:This creates:
pnpm db:seed- Sample categories
- Sample hashtags
- Sample blog posts with translations
- Published and draft content examples
3
Verify Database
Check your database setup:This opens Drizzle Studio where you can:
pnpm db:studio- View blog tables
- Check sample data
- Manually add content
- Test relationships
Admin Access
Configure admin access for content management:1
User Permissions
Blog management requires specific role permissions:Required Roles:
// Blog permissions by role
const blogPermissions = {
'blog-post:create': ['ADMIN', 'REDACTOR'],
'blog-post:read': ['ADMIN', 'REDACTOR', 'MODERATOR'],
'blog-post:update': ['ADMIN', 'REDACTOR'],
'blog-post:delete': ['ADMIN'],
'blog-post:publish': ['ADMIN', 'REDACTOR']
}ADMIN- Full blog management accessREDACTOR- Can create, edit, and publish postsMODERATOR- Can view posts only
2
Access Admin Dashboard
- Login to your application
- Ensure Admin Role in your user profile
- Navigate to
/admin/blog - Create Content using the admin interface
If you don't see the blog admin, check your user role in the database or use Drizzle Studio to update your user permissions.
Navigation Setup
Add blog links to your application navigation:// components/navigation.tsx
const navigation = [
{ name: 'Home', href: '/' },
{ name: 'Blog', href: '/blog' },
{ name: 'Documentation', href: '/blog/mdx' },
// ... other links
]SEO Configuration
Configure SEO settings for blog pages:1
Meta Tags Configuration
Blog pages automatically generate SEO meta tags:
// Automatic meta generation for blog posts
export async function generateMetadata({ params }): Promise<Metadata> {
const post = await getPostBySlug(params.slug)
return {
title: post.title,
description: post.description,
openGraph: {
title: post.title,
description: post.description,
type: 'article',
publishedTime: post.publishedAt,
},
twitter: {
card: 'summary_large_image',
title: post.title,
description: post.description,
}
}
}2
Sitemap Generation
Blog posts are automatically included in your sitemap:
// Blog posts added to sitemap.xml
const blogPosts = await getAllPublishedPosts()
const blogUrls = blogPosts.map(post => ({
url: `${baseUrl}/blog/${post.slug}`,
lastModified: post.updatedAt,
changeFrequency: 'weekly' as const,
priority: 0.7,
}))Internationalization
The blog system supports multiple languages:1
Language Configuration
Configure supported languages in your i18n setup:
// i18n/routing.ts
export const routing = defineRouting({
locales: ['en', 'fr', 'es'],
defaultLocale: 'en'
})
// Supported languages for blog content
type SupportedLanguage = 'en' | 'fr' | 'es'2
Content Translation
Blog posts automatically support multiple languages:
- Database Blog: Each post can have translations in multiple languages
- MDX Blog: Create separate MDX files for each language
- Navigation: Language switcher works with blog content
- SEO: Meta tags generated per language
Development Workflow
1
Local Development
# Start development server
pnpm dev
# Check blog functionality
# Visit: http://localhost:3000/blog
# Visit: http://localhost:3000/admin/blog2
Content Testing
# Reset and seed database with sample content
pnpm db:reset-seed
# Open database studio to manage content
pnpm db:studio
# Check blog in browser
open http://localhost:3000/blog3
Production Deployment
# Build application
pnpm build
# Run production migrations
pnpm db:migrate
# Deploy to your hosting platform
# Blog will be available at yourdomain.com/blogBlog Ready! Your blog system is now configured and ready for content creation. Visit
/admin/blog to start creating content or add MDX files to start with static content.