HTML Blocks Tutorial

Build reusable UI components with SSI

Creating Reusable HTML Widgets

Learn how to use HTML block includes to build component libraries

Index: tutorial on HTML block includes

Interactive Widget Examples

Welcome to interactive widget examples

Index page information - specific to widgets tutorial

Index: tutorial on HTML block includes

Why Use HTML Blocks and Markdown Together?

HTML blocks provide the structure (widgets, layouts, navigation), while markdown provides the content (documentation, articles, tutorials).

This separation gives you:

Real-World Example

This very tutorial uses both:

Let's explore how to build your own widget library!

Example Widgets

1. Alert Boxes

Create consistent alert components:

2. Card Components

Build reusable card layouts:

Basic Card Widget

This is a simple card component that can be reused across pages.

Learn more →

How It Works

1. Create a widget in blocks/:

<!-- blocks/alert-info.html -->
<div class="alert alert-info">
    <strong>â„šī¸ Info:</strong> 💬alert-message
</div>

2. Configure in ssi-config.toml:

[[step]]
emoji = "📎"
path = "blocks"
processing = "html"

3. Use anywhere with 📎widget-name:

<section>
    <h2>Notifications</h2>
    📎alert-info
    📎alert-warning
</section>

Guidelines

📝 Use Semantic HTML

Structure your templates with meaningful HTML5 elements.

🎨 Separate Concerns

Keep content, structure, and presentation in separate files.

🔧 Reuse Components

Create reusable blocks for common UI patterns.

⚡ Optimize Loading

Minimize file sizes and reduce HTTP requests.

â™ŋ Ensure Accessibility

Follow WCAG guidelines for inclusive design.

📱 Mobile First

Design for mobile devices, then enhance for larger screens.

For More Complex Needs

This example shows static HTML blocks — each block is always the same content. For blocks that render different content for each item (like a product card that displays data from a TOML file, or a blog post card that shows a different title and excerpt per post), see Example 11: Include Templates, which covers template rendering with directory and TOML data sources.