Statamic Custom Template Development (Antlers/Blade)
Statamic supports both template engines: Antlers (proprietary, recommended) and Blade (Laravel standard). The choice depends on your team: Antlers is simpler for content-oriented templates, Blade is familiar to Laravel developers and supports components.
Antlers vs Blade
| Antlers | Blade | |
|---|---|---|
| Syntax | {{ collection:blog }} |
@foreach($blog as $item) |
| Variables | {{ title }} |
{{ $title }} |
| Statamic Tags | Native | Via facades |
| Components | Partials | Blade Components |
| Performance | Similar | Similar |
Antlers: template structure
{{# resources/views/layouts/app.antlers.html #}}
<!DOCTYPE html>
<html lang="{{ locale:language }}">
<head>
<meta charset="utf-8">
<title>
{{ if meta_title }}{{ meta_title }} | {{ /if }}{{ site:name }}
</title>
<meta name="description" content="{{ meta_description ?? excerpt ?? '' | truncate:160 }}">
{{ vite src="resources/js/app.js|resources/css/app.css" }}
</head>
<body>
{{ partial:navigation :items="navigation:main" }}
<main>{{ template_content }}</main>
{{ partial:footer }}
</body>
</html>
Antlers: working with data
{{# Conditions #}}
{{ if is_premium and (user:is_logged_in or not config:require_login) }}
{{ content }}
{{ elseif user:is_logged_in }}
<p>Upgrade to Premium</p>
{{ else }}
<p>Please log in</p>
{{ /if }}
{{# Loop with nested data #}}
{{ collection:blog sort="date:desc" limit="6" }}
{{ results }}
<article>
<h2>{{ title }}</h2>
{{ categories }}
<a href="{{ url }}">{{ title }}</a>{{ unless last }}, {{ /unless }}
{{ /categories }}
{{ date format="d.m.Y" }}
</article>
{{ /results }}
{{ /collection:blog }}
{{# Scope — data isolation #}}
{{ scope:post }}
{{ collection:blog limit="1" }}
{{ results }}
{{ scope:category }}
{{ categories }}
{{ title }}: {{ post:title }}
{{ /categories }}
{{ /scope:category }}
{{ /results }}
{{ /collection:blog }}
{{ /scope:post }}
Blade: Statamic templates
{{-- resources/views/layouts/app.blade.php --}}
<!DOCTYPE html>
<html lang="{{ Statamic::tag('locale:language') }}">
<head>
<title>{{ $page->get('meta_title') ?? $page->get('title') }} | {{ config('app.name') }}</title>
@vite(['resources/css/app.css', 'resources/js/app.ts'])
</head>
<body>
@include('partials.navigation')
<main>@yield('content')</main>
@include('partials.footer')
</body>
</html>
{{-- resources/views/blog/index.blade.php --}}
@extends('layouts.app')
@section('content')
<div class="blog-grid">
@foreach($entries as $post)
<x-post-card :post="$post" />
@endforeach
</div>
{{ $paginator->links() }}
@endsection
Blade component for post:
{{-- resources/views/components/post-card.blade.php --}}
@props(['post'])
<article>
@if($post->get('featured_image'))
<img src="{{ Statamic::tag('glide')->src($post->get('featured_image'))->width(800)->height(400)->fit('crop')->fetch() }}"
alt="{{ $post->get('title') }}">
@endif
<h2><a href="{{ $post->url() }}">{{ $post->get('title') }}</a></h2>
<time>{{ $post->date()->format('d.m.Y') }}</time>
</article>
Partial with parameters
{{# Call partial #}}
{{ partial:card
title="{ title }"
url="{ url }"
image="{ featured_image }"
show_excerpt="true"
}}
{{# resources/views/partials/card.antlers.html #}}
<article class="card {{ if show_excerpt }}card--with-excerpt{{ /if }}">
{{ if image }}
<img src="{{ image | glide:width=600:height=400:fit=crop }}" alt="{{ title }}">
{{ /if }}
<h3><a href="{{ url }}">{{ title }}</a></h3>
{{ if show_excerpt && excerpt }}
<p>{{ excerpt | truncate:120 }}</p>
{{ /if }}
</article>
Navigation with tree
{{ nav:main }}
<ul>
{{ tree }}
<li class="{{ if page:is_current || page:is_parent }}active{{ /if }}">
<a href="{{ url }}">{{ title }}</a>
{{ if children }}
<ul>
{{ children }}
<li><a href="{{ url }}">{{ title }}</a></li>
{{ /children }}
</ul>
{{ /if }}
</li>
{{ /tree }}
</ul>
{{ /nav:main }}
Template development (layout, nav, footer, list, detail, static pages) — 4–8 days.







