A beautiful, modern static blog built with Blazor WebAssembly and .NET 9. Features markdown/MDX support, dark mode, and premium styling.
✨ Modern Design
- Clean, elegant interface with premium styling
- Responsive layout that works on all devices
- Smooth animations and polished UI components
- Light/dark theme support with system preference detection
🚀 Blazor WebAssembly
- Fully client-side application
- No backend required
- Fast, app-like experience
- Static hosting compatible
📝 Content Management
- Write posts in Markdown (.md) or MDX (.mdx)
- Support for frontmatter metadata
- File-driven content (no CMS needed)
- Custom component support via shortcodes
🎨 Theming
- Automatic dark/light mode
- Respects system preferences
- Theme persistence with localStorage
- CSS custom properties for easy customization
📱 Responsive & Accessible
- Mobile-first design
- Touch-friendly interactions
- Accessible markup and navigation
- Progressive Web App ready
- .NET 9 SDK
- A code editor (VS Code recommended)
-
Clone or download this template
git clone <your-repo-url> cd blazor-blog
-
Restore dependencies
dotnet restore
-
Run the development server
dotnet run
-
Open your browser to
https://localhost:5001
-
Create a new blog post in the
Content/folder:touch Content/my-new-post.md
-
Add frontmatter and content:
--- title: "My Amazing Post" slug: "my-amazing-post" author: "Your Name" publishDate: 2024-01-15T10:00:00Z summary: "This is what my post is about" tags: ["technology", "blazor"] format: "md" draft: false --- # My Amazing Post Your content goes here...
-
Update the manifest at
wwwroot/content/manifest.json:[ "welcome-to-my-blog.md", "my-new-post.md" ]
-
Build and see your changes:
dotnet build dotnet run
title: Post title (required)slug: URL slug (required, auto-generated if not provided)author: Author name (required)publishDate: ISO 8601 date (required)summary: Brief description (optional but recommended)tags: Array of tags (optional)format: "md" or "mdx" (optional, defaults to file extension)category: Post category (optional)featuredImage: Path to featured image (optional)draft: Boolean to hide from public (optional, defaults to false)
Use shortcodes to add rich components to your content:
[[Alert type="info" title="Note" message="This is an informational alert"]]
[[Callout type="warning" title="Important" content="Pay attention to this"]]
[[Image src="/images/photo.jpg" alt="Description" caption="Photo caption"]]
[[Quote quote="Great things are done by a series of small things brought together." author="Vincent Van Gogh"]]This blog can be deployed to any static hosting platform:
- Connect your repository to Azure Static Web Apps
- Use these build settings:
- Build command:
dotnet publish -c Release -o dist - App artifact location:
dist/wwwroot
- Build command:
- Enable GitHub Pages in your repository settings
- Add a GitHub Action for automated deployment:
name: Deploy to GitHub Pages on: push: branches: [ main ] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: '9.0.x' - name: Publish run: dotnet publish -c Release -o dist - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: dist/wwwroot
- Connect your repository to Netlify
- Use these build settings:
- Build command:
dotnet publish -c Release -o dist - Publish directory:
dist/wwwroot
- Build command:
The blog uses CSS custom properties for theming. You can customize colors, fonts, and spacing by modifying the CSS variables in wwwroot/css/app.css:
:root {
--primary-color: #3b82f6; /* Blue */
--accent-color: #a855f7; /* Purple */
--background: #ffffff; /* White */
--text-color: #0f172a; /* Dark gray */
/* ... more variables */
}- Create a new Blazor component in
Components/ - Add it to the shortcode processor in
Services/MarkdownService.cs - Use it in your content with shortcode syntax
- Navigation: Edit
Components/Layout/NavMenu.razor - Main Layout: Edit
Components/Layout/MainLayout.razor - Theme Toggle: Edit
Components/Layout/ThemeToggle.razor
/
├── Components/ # Blazor components
│ └── Layout/ # Layout components
├── Content/ # Blog post files (*.md, *.mdx)
├── Models/ # Data models
├── Pages/ # Page components
├── Services/ # Application services
├── wwwroot/ # Static web assets
│ ├── css/ # Stylesheets
│ └── content/ # Copied blog content (build output)
├── Blog.csproj # Project file
└── Program.cs # Application entry point
- Blazor WebAssembly - Client-side web framework
- .NET 9 - Runtime and SDK
- Markdig - Markdown processing
- YamlDotNet - YAML frontmatter parsing
- Modern CSS - Responsive design with CSS Grid and custom properties
This project is open source. Feel free to use it as a template for your own blog!
Contributions are welcome! Please feel free to submit issues or pull requests.
Happy blogging! 🚀